NetZero Chain

Deploying Contracts

From an agent wallet

agent_deployContract(from, bytecode, value?) sends a creation transaction. bytecode is the hex creation code your compiler produced (bin, not bin-runtime), including any constructor arguments ABI-encoded and appended.

curl -s -X POST http://127.0.0.1:8545 -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"agent_deployContract","params":["0xYourAgentWallet","0x6080604052…",null],"id":1}'

Then read the receipt:

curl -s -X POST http://127.0.0.1:8545 -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"agent_getTransactionReceipt","params":["0xTxHash"],"id":1}'
# → { "status": "0x1", "contractAddress": "0xf88c…", ... }

Compile

Any Solidity compiler works. The EVM level is Shanghai; solc >= 0.8.20 targets it by default. Example with solc on the command line:

solc --bin --abi --evm-version shanghai Counter.sol -o build/

Constructor arguments

Append them ABI-encoded to the creation bytecode. With ethers:

import { ethers } from "ethers";
const iface = new ethers.Interface(abi);
const data = bytecode + iface.encodeDeploy([arg1, arg2]).slice(2);
// pass `data` as the bytecode parameter of agent_deployContract

Costs

Deployment gas is dominated by code size: 200 gas per byte of runtime code plus execution. A 4 KB contract costs roughly 1,000,000 gas, which at the 1,000 gwei floor is about 1 USDn. Half of that goes to carbon removals.

Smallest possible example

The creation code below deploys a contract whose only behaviour is to return 42:

0x600a600c600039600a6000f3602a60005260206000f3

Deploy it, then call it with agent_callContract(address, "0x") and you get 0x…2a. This is the exact sequence the testnet was verified with.