Follow these steps to deploy the CofiBlocks contracts on the StarkNet network.
Set the following environment variables in your .env file with the details of a prefunded wallet. This wallet will act as the admin address:
-
PRIVATE_KEY_MAINNET– The private key of the admin wallet. -
ACCOUNT_ADDRESS_MAINNET– The address of the admin wallet. -
TOKEN_METADATA_URL– The IPFS URL to serve as the token metadata. -
RPC_URL_MAINNET– The rpc url to use to connect to the starknet network.The Token Metadata URL should follow the format:
ipfs://<CID>/{id}.json, where{id}will be dynamically replaced with the actual token ID by clients when fetching metadata.Example:
ipfs://bafybeihevtihdmcjkdh6sjdtkbdjnngbfdlr3tjk2dfmvd3demdm57o3va/{id}.jsonFor token ID
1, the resulting URL will be:ipfs://bafybeihevtihdmcjkdh6sjdtkbdjnngbfdlr3tjk2dfmvd3demdm57o3va/1.json
Run the following command to install project dependencies:
bun iTo deploy the contracts on mainnet, run:
bun deployThis command will:
- Deploy contracts CofiCollections, Marketplace and Distribution.
- Set the Marketplace contract as the minter in the CofiCollection contract.
- Set the distribution contract on Marketplace.
- Set the
base_uriin the CofiCollection contract using theTOKEN_METADATA_URLvalue from the.envfile.
Once the deployment is complete, the contract addresses will be available in:
- The terminal output.
- The file located at:
deployments/deployedContracts.ts.
To test the contracts, follow these steps.
- Go to contracts folder
cd contracts- Run test command
scarb test