Skip to content

Instantly share code, notes, and snippets.

@MicahZoltu
Last active December 16, 2020 09:15
Show Gist options
  • Save MicahZoltu/7d06067e1a3c2b42119ea14b6be15bce to your computer and use it in GitHub Desktop.
Save MicahZoltu/7d06067e1a3c2b42119ea14b6be15bce to your computer and use it in GitHub Desktop.
Augur ENS Verification

Requirements

Docker

Building and Running the Augur ENS Tool

  1. Download (or copy/paste into file) the attached Dockerfile to any folder
  2. From a command prompt in the folder with the Dockerfile run the following (replace IPFS hashes with latest official hashes):
    # once
    docker image build --tag augur-ens-verification-tool .
    # every time
    docker container run \
      --rm \
      -it \
      -e TRADING_CIDV0_IPFS_HASH=QmNSTVkYTSpLhBCzD1K8QJczXcpNeph4ySveDesspE5iY4 \
      -e REPORTING_CIDV0_IPFS_HASH=QmWhihA1TiDoZbyfrmYbPUnYdbUiYaEgjTMGat29Xk5ctZ \
      augur-ens-verification-tool

Update ENS Record

  1. Run the tool (see above)
  2. In Aragon: click ⚙️ at the top right of screen, go into Help and feedback, and enable Display the console ~
  3. In Aragon: Console => Act => Agent
  4. Set ENS Resolver (found at https://app.ens.domains/name/augur2.eth) as the target address
  5. Set setContenthash(bytes32: <nameHash>, bytes: <contentHash>) for the method (where and are from Augur ENS Tool output)
  6. Verify the full console command is: act/agentAddress/resolverAddress/setContenthash(bytes32: <nameHash>, bytes: <contentHash>)
  7. Repeat above steps for https://app.ens.domains/name/trading.augur2.eth and https://app.ens.domains/name/reporting.augur2.eth

Verifying Vote

  1. Look up the transaction that initiated the Aragon vote in EtherScan or similar tool
  2. Verify the end of the transaction input data matches the Transaction in the Augur ENS Tool output
FROM node:14-alpine
WORKDIR /app
RUN npm install --save eth-ens-namehash content-hash @zoltu/ethereum-abi-encoder
RUN echo $'\n\
import Contenthash from "content-hash"\n\
import Namehash from "eth-ens-namehash"\n\
import AbiEncoder from "@zoltu/ethereum-abi-encoder"\n\
\n\
function stringToBytes(hex) {\n\
const match = /^(?:0x)?([a-fA-F0-9]*)$/.exec(hex)\n\
if (match === null) throw new Error(`Expected a hex string encoded byte array with an optional "0x" prefix but received ${hex}`)\n\
const normalized = match[1]\n\
if (normalized.length % 2) throw new Error(`Hex string encoded byte array must be an even number of charcaters long.`)\n\
const bytes = []\n\
for (let i = 0; i < normalized.length; i += 2) {\n\
bytes.push(Number.parseInt(`${normalized[i]}${normalized[i + 1]}`, 16))\n\
}\n\
return new Uint8Array(bytes)\n\
}\n\
\n\
const nameHash = Namehash.hash("augur2.eth")\n\
console.log(`\x1b[1mName Hash (augur2.eth)\x1b[0m: ${nameHash}`)\n\
const tradingNameHash = Namehash.hash("trading.augur2.eth")\n\
console.log(`\x1b[1mName Hash (trading.augur2.eth)\x1b[0m: ${tradingNameHash}`)\n\
const reportingNameHash = Namehash.hash("reporting.augur2.eth")\n\
console.log(`\x1b[1mName Hash (reporting.augur2.eth)\x1b[0m: ${reportingNameHash}`)\n\
\n\
const tradingContentHash = `0x${Contenthash.fromIpfs(process.env.TRADING_CIDV0_IPFS_HASH)}`\n\
const reportingContentHash = `0x${Contenthash.fromIpfs(process.env.REPORTING_CIDV0_IPFS_HASH)}`\n\
console.log(`\x1b[1mContent Hash (Trading)\x1b[0m: ${tradingContentHash}`)\n\
console.log(`\x1b[1mContent Hash (Reporting)\x1b[0m: ${reportingContentHash}`)\n\
\n\
const rootMethodCall = AbiEncoder.encodeMethod(0x304e6ade, [{ name: "node", type: "bytes32" }, { name: "hash", type: "bytes" }], [BigInt(nameHash), stringToBytes(tradingContentHash)])\n\
console.log(`\x1b[1mTransaction (augur2.eth)\x1b[0m: ${Array.from(rootMethodCall).map(x => x.toString(16).padStart(2, "0")).join("")}`)\n\
const tradingMethodCall = AbiEncoder.encodeMethod(0x304e6ade, [{ name: "node", type: "bytes32" }, { name: "hash", type: "bytes" }], [BigInt(tradingNameHash), stringToBytes(tradingContentHash)])\n\
console.log(`\x1b[1mTransaction (trading.augur2.eth)\x1b[0m: ${Array.from(tradingMethodCall).map(x => x.toString(16).padStart(2, "0")).join("")}`)\n\
const reportingMethodCall = AbiEncoder.encodeMethod(0x304e6ade, [{ name: "node", type: "bytes32" }, { name: "hash", type: "bytes" }], [BigInt(reportingNameHash), stringToBytes(reportingContentHash)])\n\
console.log(`\x1b[1mTransaction (reporting.augur2.eth)\x1b[0m: ${Array.from(reportingMethodCall).map(x => x.toString(16).padStart(2, "0")).join("")}`)\n\
' >> /app/index.mjs
ENTRYPOINT [ "node", "index.mjs" ]
@CrystalBallBe
Copy link

@MicahZoltu
I want you to add the following text to the end of 2. In Aragon: Console => Act => Agent (​you can change the wording).

 (If you cannot find `Console` in Aragon, click ⚙️ at the top right of screen and go into `Help and feedback`. And turn the toggle switch `Display the console ~` enabled, then `Console` will appear on the side navigation bar.)

FWIW I wanted to make a pull request to do this but I couldn't. As you might already know you cannot make a pull request on a Gist. I didn't know that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment