deployment of BonsaiOFT to zksync, base, and lens chain - with 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
BonsaiOFTAdapterto polygonBonsaiOFTto Base (with cli)BonsaiOFTto zkSync Era + Lens Chain (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 compileToggle only the polygon network with [SPACE] and set the tag as BonsaiOFTAdapter
npx hardhat lz:deployToggle only the base network with [SPACE] and set the tag as BonsaiOFT
npx hardhat lz:deployRead: 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" --verifyManually 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 324We need to set the peers on all contracts, and set enforcedOptions for the Stargate listing requirement. Everything is configured in *.layerzero.config.ts
https://docs.layerzero.network/v2/developers/evm/technical-reference/dvn-addresses
https://docs.layerzero.network/v2/developers/evm/technical-reference/deployed-contracts
yarn wirethen, check the tx on layerzeroscan: https://layerzeroscan.com
forge script script/mainnet/Bridge.s.sol:LzSendPolygon --rpc-url polygon -vvvv --broadcastthen, check the tx on layerzeroscan: https://layerzeroscan.com
forge script script/mainnet/Bridge.s.sol:LzSendBase --rpc-url base -vvvv --broadcastthen, check the tx on layerzeroscan: https://layerzeroscan.com
forge script script/mainnet/Bridge.s.sol:LzSendZkSync --rpc-url zksync -vvvv --broadcastforge script script/mainnet/Read.s.sol:Read --rpc-url base -vvvvzksync-cli contract read --chain "zksync" --contract "0xB0588f9A9cADe7CD5f194a5fe77AcD6A58250f82" --method "mirror()" --output "address"npx hardhat verify --network polygon --constructor-args ./utils/verify/bonsaiOFTAdapter.ts 0x303b63e785B656ca56ea5A5C1634Ab20C98895e1npx hardhat verify --network base --constructor-args ./utils/verify/bonsaiOFT.ts 0x474f4cb764df9da079D94052fED39625c147C12CFail - Unable to verify. Compiled contract runtime bytecode does NOT match the on-chain runtime bytecode.
forge verify-contract 0xB0588f9A9cADe7CD5f194a5fe77AcD6A58250f82 contracts/BonsaiOFT.sol:BonsaiOFT --chain-id 324 --watch --zksync --constructor-args $(cast abi-encode "constructor(uint96,address,address)" 100000 "0xd07C30aF3Ff30D96BDc9c6044958230Eb797DDBF" "0x21af1185734d213d45c6236146fb81e2b0e8b821")
forge verify-contract \
--zksync \
--watch \
--verifier zksync \
--verifier-url https://api-explorer-verify.lens.matterhosted.dev/contract_verification \
--constructor-args $(cast abi-encode "constructor(uint96,address,address)" 100000 0x5c6cfF4b7C49805F8295Ff73C204ac83f3bC4AE7 0x21af1185734d213d45c6236146fb81e2b0e8b821) \
0xB0588f9A9cADe7CD5f194a5fe77AcD6A58250f82 \
contracts/BonsaiOFT.sol:BonsaiOFT