Account
Let's create the claimer and the attester account.
In ProofID, there is an account which is an object that interacts with the blockchain.
An accounts contains multiple properties.
One of them is the address
: it's the entity's unique and public on-chain identifier.
ProofID Account
A ProofID account is a set of cryptographic elements:
- The address, which is generated from the public key
- A signing keypair write transactions on-chain
All we need to create an account is a mnemonic.
mnemonic
In cryptography, a mnemonic usually consists of 12 or 24 random series of words.
For example, gold upset segment cake universe
is a mnemonic.
It's used to generate signing keypairs.
What's great about a mnemonic is that it's human-readable.
A person can memorize it, and use it later to re-generate their keypairs and address.
Create a file
Create a new file account.js
.
All of the code for this step needs to go into this file.
Code
To generate an account, one method from the ProofID SDK is needed and one method from the polkadot crypto utility:
mnemonicGenerate()
// Generates a mnemonicaddFromMnemonic(mnemonic)
// takes a mnemonic as an input, and outputs anAccount
instance.
Open account.js
and paste the following code:
const ProofID = require('@proofid/pid-ts-lib')
const { mnemonicGenerate } = require('@polkadot/util-crypto')
function account() {
const mnemonic = mnemonicGenerate()
console.log('mnemonic:', mnemonic)
const keyring = new ProofID.Utils.Keyring({
ss58Format: 42,
type: 'ed25519',
})
const account = keyring.addFromMnemonic(mnemonic)
console.log('address:', account.address)
}
module.exports.account = account
You're now ready to generate an account.
Run
To generate an account, run this command in your terminal, still within your pid-app
directory:
node account.js
Your output should look like this (but it won't be identical since the mnemonic is randomly generated):
Mnemonic: gold upset segment cake universe carry demand comfort dawn invite element capital
Address: 5CUoo2vAegeaZHPNdxZyuMesR3RWYBKHj4jfVyj4FXzpXPuR
You want to run this command twice, in order to generate 2 accounts:
the attester's and the claimer's.
Hence, create a new file called accounts.js
with the following code:
const ProofID = require('@proofid/pid-ts-lib')
const { mnemonicGenerate } = require('@polkadot/util-crypto')
function accounts() {
const keyring = new ProofID.Utils.Keyring({
ss58Format: 42,
type: 'ed25519',
})
const claimerMnemonic = mnemonicGenerate()
console.log('claimer mnemonic:', claimerMnemonic)
const claimer = keyring.addFromMnemonic(claimerMnemonic)
console.log('claimer address:', claimer.address)
const attesterMnemonic = mnemonicGenerate()
console.log('attester mnemonic:', attesterMnemonic)
const attester = keyring.addFromMnemonic(attesterMnemonic)
console.log('attester address:', attester.address)
return { claimer, claimerMnemonic, attester, attesterMnemonic }
}
module.exports.accounts = accounts
Copy and paste the two mnemonics and addresses in a new file called index.js
, you'll need them soon.
// Copy created addresses and mnemonics from accounts.js
const claimerMnemonic = `<generatedClaimerMnemonic>`
const claimerAddress = `<generatedClaimerAddress>`
const attesterMnemonic = `<generatedAttesterMnemonic>`
const attesterAddress = `<generatedAttesterAddress>`
In the next steps, we'll refer to the so-generated accounts as follows:
<claimerMnemonic>
is the mnemonic for the claimer and<claimerAddress>
the claimer's associated address;<attesterMnemonic>
is the mnemonic for the attester and<attesterAddress>
the attester's associated address.
Request PID tokens
When writing the hash of attestations on the blockchain, attesters have to pay the angel’s share (gas or transaction fee) and the deposit in ProofID Tokens. So you'll need tokens to attest a claim.
If you haven't already requested ProofID tokens, go to the (telegram) and request tokens for your <attesterAddress>
.
Sadly these are just play tokens, not real money.
That's it - You've successfully generated two new on-chain accounts and their associated addresses!