Deploy Registry Contract
This guide covers the deployment of the ERC-6551 Registry contract for the purpose of interacting with TBAs (Tokenbound Accounts) on a local node OR if you want to enable TBAs for the first time on a new EVM chain. Otherwise, you may use the existing canonical ERC-6551 Registry contract.
The ERC-6551 Registry contract has already been deployed across several EVM networks. A list of deployed addresses can be found here.
Pre-Requisites
-
foundry
If you do not have foundry already:
$ curl -L https://foundry.paradigm.xyz | bash
$ foundryup
-
terminal
Clone the Reference repository
$ git clone https://github.com/erc6551/reference.git
Make sure you checkout on v0.2.0
tag for the repository
This is ensures that the address of Registry contract is the same as on any other EVM compatible chain. The current address that’s deployed on all chains is: 0x02101dfB77FDE026414827Fdc604ddAF224F0921
$ git checkout tags/v0.2.0
If this address differs it would cause a tokenbound account associated with an NFT to have different addresses on different chains (we do not want that)
Run the test and build the contracts
$ forge test
$ forge build
Compute the Registry address
This is to make sure it matches with 0x02101dfB77FDE026414827Fdc604ddAF224F0921
$ forge script script/ComputeRegistryAddress.s.sol:ComputeRegistryAddress
The output should be:
[â ’] Compiling... No files changed, compilation skipped Script ran successfully. Gas
used: 24925
== Logs ==
0x02101dfB77FDE026414827Fdc604ddAF224F0921
make sure the Address matches with
0x02101dfB77FDE026414827Fdc604ddAF224F0921
Deploy
Before we can deploy we need to provide MAINNET_PRIVATE_KEY
env variable - set this to your test account’s private key
$ forge script --fork-url <RPC_URL> script/DeployRegistry.s.sol --broadcast
replace <RPC_URL>
with your chain's RPC endpoint