Skip to content

Instantly share code, notes, and snippets.

@joepetrowski
Created July 15, 2020 06:37
Show Gist options
  • Save joepetrowski/9787709c46943e3de38c33a0ea59d397 to your computer and use it in GitHub Desktop.
Save joepetrowski/9787709c46943e3de38c33a0ea59d397 to your computer and use it in GitHub Desktop.

This is a guide to test claims on a local testnet for wallet integrations.

Generate a Chainspec

Clone the chainspec generator and follow the instructions in the README. You only need to run up to ./scripts/polkadot-genesis.sh, and you will get the chainspec that was used for Polkadot genesis.

This will output a polkadot.json file; rename it to something like modified-polkadot.json.

Get Runtime Code

You will have to modify and compile a Polkadot client.

  1. Clone the Polkadot repo.
  2. Check out the version that corresponds to the current runtime. E.g., if Polkadot is on v14, check out v0.8.14.
  3. Go to the /service/src/chain_spec.rs file. You need to set endowed_accounts, otherwise generating the code will panic. In v0.8.14, this is line 118. Set this to:
let endowed_accounts = vec![
	hex!["e5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a"].into(),
];
  1. Compile (cargo build --release) and go get a coffee or a beer.
  2. Once that is done, run ./target/release/polkadot build-spec --chain polkadot-staging > staging.json.

Copy Runtime Code

Go into staging.json and find the long hex blob under the "code" key. This is the most up-to-date runtime. Copy this into the modified-polkadot.json file.

Add Your Custom Accounts

Now that you have the correct runtime code, you can add some custom accounts to your modified-polkadot.json file. Scroll to the end of the file and you will see a lot of claims in the spec, just add your own that you want to test. Claims take the form of:

[
  ethereum address,
  number of tokens,
  polkadot address (may be `null`),
  sale agreement ("Regular" or "Saft"),
]

A Polkadot address of null means that the person did not pre-claim and needs to submit a claims.claimAttest transaction, which will require a signature from the Ethereum key. A non-null Polkadot address means that the person did pre-claim and will need to submit a claims.attest transaction.

Examples:

A non-pre-claimed address with 23 DOTs.

[
  "0xBa3fb82687f28ce414dCb4803D05EacAcb697DB4",
  23000000000000,
  null,
  "Regular"
],

A pre-claimed address with 82 DOTs.

[
  "0x4bD120e887Cc82285AFF8408DC208eD32B132Bb3",
  82000000000000,
  "12uMj2RetfZtkoezt4pJwS79rfbJcxmGHMXT5mw7QnxreAqV",
  "Regular"
],

Start Your Chain

Start your chain with ./target/release/polkadot --chain modified-polkadot.json --validator --alice. You can now access this via Polkadot JS Apps or any other way you'd interact with the chain.

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