Contracts

Get Started

Read, write, and deploy smart contracts on any EVM compatible blockchain.

Read from Contracts

You can efficiently read data from multiple functions or contracts in a single request.

Request

fetch("https://api.thirdweb.com/v1/contracts/read", {
method: "POST",
headers: {
"x-secret-key": "<your-project-secret-key>",
},
body: {
calls: [
{
contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
method: "function name() view returns (string)",
},
{
contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
method: "function totalSupply() returns (uint256)",
},
{
contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
method: "function balanceOf(address) returns (uint256)",
params: ["0x742d35Cc6634C0532925a3b8D43C67B8c8B3E9C6"],
},
],
chainId: 8453,
},
});

Response

{
"result": [
{
"success": true,
"data": "value",
"error": "string"
}
]
}

Write to Contracts

You can write multiple functions to multiple contracts on the same chain in a single request atomically, which will result in a single transaction for optimal gas efficiency.

Request

fetch("https://api.thirdweb.com/v1/contracts/write", {
method: "POST",
headers: {
"x-secret-key": "<your-project-secret-key>",
},
body: {
calls: [
{
contractAddress: "0xe352Cf5f74e3ACfd2d59EcCee6373d2Aa996086e",
method: "function approve(address spender, uint256 amount)",
params: [
"0x4fA9230f4E8978462cE7Bf8e6b5a2588da5F4264",
1000000000,
],
},
],
chainId: 84532,
from: "0x1234567890123456789012345678901234567890",
},
});

Response

{
"result": {
"transactionIds": [
"string"
]
}
}

Going further

Explore Full API References

For comprehensive guides on implementing the full thirdweb SDK, explore our language-specific documentation: