deployment of BonsaiOFT to zksync, base, and the BonsaiOFTAdapter to polygon
this repo was created using the zksync-cli: https://docs.zksync.io/build/zksync-cli
to build the contracts for zksync era, we use foundry-zksync: https://docs.zksync.io/build/tooling/foundry/overview
Set up deployer wallet/account:
- Rename
.env.example
->.env
- Set private key for both formats
- Fund this address with the corresponding chain's native tokens you want to deploy to.
We're going to deploy
BonsaiOFTAdapter
to polygonBonsaiOFT
to Base (with cli)BonsaiOFT
to zkSync Era (with foundry)
All scripts set the base uri to the current NFT uri; No initial supply is set for BonsaiOFT contracts on Base/zkSync
pnpm compile
Toggle only the polygon network with [SPACE] and set the tag as BonsaiOFTAdapter
npx hardhat lz:deploy
Toggle only the base network with [SPACE] and set the tag as BonsaiOFT
npx hardhat lz:deploy
Read: https://docs.zksync.io/build/tooling/foundry/getting-started#deploying-smart-contracts-with-forge
To deploy to zksync, use foundry create
pnpm compile:forge:zksync
forge create contracts/BonsaiOFT.sol:BonsaiOFT --account myKeystore --rpc-url zksync --chain 324 --zksync --constructor-args 100000 "0xd07C30aF3Ff30D96BDc9c6044958230Eb797DDBF" "0x21aF1185734D213D45C6236146fb81E2b0E8b821" --verify
Manually save the deployed contract address in addresses.json
And send the setBaseURI
tx
cast send 0xB0588f9A9cADe7CD5f194a5fe77AcD6A58250f82 "setBaseURI(string)" "ipfs://bafybeiba7hsqirohcgqibxokpml7eoh65z7fagah7ed7ggejud265ro2ky/" --account myKeystore --rpc-url zksync --chain 324
We need to set the peers on all contracts, and set enforcedOptions
for the Stargate listing requirement. Everything is configured in *.layerzero.config.ts
yarn wire
then, check the tx on layerzeroscan: https://layerzeroscan.com
forge script script/mainnet/Bridge.s.sol:LzSendPolygon --rpc-url polygon -vvvv --broadcast
forge script script/mainnet/Read.s.sol:Read --rpc-url base -vvvv
zksync-cli contract read --chain "zksync" --contract "0xB0588f9A9cADe7CD5f194a5fe77AcD6A58250f82" --method "mirror()" --output "address"
npx hardhat verify --network polygon --constructor-args ./utils/verify/bonsaiOFTAdapter.ts 0x303b63e785B656ca56ea5A5C1634Ab20C98895e1
npx hardhat verify --network base --constructor-args ./utils/verify/bonsaiOFT.ts 0x474f4cb764df9da079D94052fED39625c147C12C
Fail - Unable to verify. Compiled contract runtime bytecode does NOT match the on-chain runtime bytecode.
forge verify-contract 0xe86B6e5381C2641c2dfA247628481f1dEd18DCC7 contracts/BonsaiOFT.sol:BonsaiOFT --chain-id 300 --watch --zksync --constructor-args $(cast abi-encode "constructor(uint96,address,address)" 100000 "0xe2Ef622A13e71D9Dd2BBd12cd4b27e1516FA8a09" "0x21af1185734d213d45c6236146fb81e2b0e8b821")