A handy TypeScript program to update your BCMR metadata on-chain!
A program to import a single-address wallet for creating an OP_RETURN output in the authchain to publish a BCMR metadata update for a token or identity.
Also includes helper programs for adding or removing fungible tokens from the authchain reserved supply.
Be careful with any program asking you to fill in your seedphrase! Verify the source of the program and that is doing what it claims to be doing!
Before starting, it is expected that you hold the AuthHead in either a dedicated wallet used for no other purpose or a wallet with coin-control to prevent accidental burning.
Clone this repo locally & have Node.js installed to run the programs. Install the dependencies in the command line with
pnpm installNext, fill in the 5 variables at the top of the authUpdate.ts file
- the
tokenId(or authbase) - either the
bcmrURLor thebcmrIpfsCID - the
seedphase - the
derivationPathAddress keepReservedSupplyboolean
For the derivationPathAddress: if your authHead is at address index 4 in your Electron Cash, change m/44'/145'/0'/0/0 to m/44'/145'/0'/0/4.
Instead of editing the file, authUpdate also takes these from the environment, which keeps your keys out of the source: TOKEN_ID, NETWORK (mainnet or chipnet), BCMR_URL or BCMR_IPFS_CID, and WIF or SEEDPHRASE. Run pnpm run authUpdate:dryRun (or set DRY_RUN=true) to check the wallet, the authhead and the BCMR hash without broadcasting.
The authhead is looked up on the public mainnet Chaingraph instance. For chipnet, set CHAINGRAPH_URL to a Chaingraph instance that indexes chipnet. When set, CHAINGRAPH_URL is used for every network, so unset it again before a mainnet run.
Before publishing, authUpdate checks that the fetched BCMR is JSON with an identity for your token.
Finally run the program from the command line with
pnpm run authUpdateto broadcast the onchain metadata update. To use this program you need enough BCH in the single-address wallet to cover the network fees of the transaction.
The program imports a one-address wallet from the provided seedphrase and creates a transaction to publish an on-chain BCMR update in the authchain. More specifically, it sends the authhead back to the same address and has an OP_RETURN as second output to put data for the BCMR update on-chain according to the BCMR spec:
OP_RETURN <'BCMR'> <hash> <uri>
There is also a helper program to issue fungible token supply from an an authchain:
pnpm run issueSupplyThere is also a helper program to add fungible token supply to the reserved supply:
pnpm run reservedSupply