跳转到主要内容
POST
/
v1
/
wallets
/
{walletId}
/
contracts
/
write
Master Wallet Write
curl --request POST \
  --url https://api.blockradar.co/v1/wallets/{walletId}/contracts/write \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "calls": [
    {
      "abi": [
        {
          "constant": false,
          "inputs": [
            {
              "name": "_to",
              "type": "address"
            },
            {
              "name": "_value",
              "type": "uint256"
            }
          ],
          "name": "transfer",
          "outputs": [],
          "payable": false,
          "stateMutability": "nonpayable",
          "type": "function"
        }
      ],
      "address": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
      "method": "transfer",
      "parameters": [
        "0x2455eC6700092991Ce0782365A89d5Cd89c8Fa22",
        "10000"
      ]
    },
    {
      "abi": [
        {
          "constant": false,
          "inputs": [
            {
              "name": "_to",
              "type": "address"
            },
            {
              "name": "_value",
              "type": "uint256"
            }
          ],
          "name": "transfer",
          "outputs": [],
          "payable": false,
          "stateMutability": "nonpayable",
          "type": "function"
        }
      ],
      "address": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
      "method": "transfer",
      "parameters": [
        "0x2455eC6700092991Ce0782365A89d5Cd89c8Fa22",
        "10000"
      ]
    }
  ]
}
'
{
"data": {
"amlScreening": null,
"amountPaid": null,
"assetSwept": null,
"assetSweptAmount": null,
"assetSweptAt": null,
"assetSweptGasFee": null,
"assetSweptHash": null,
"assetSweptRecipientAddress": null,
"assetSweptResponse": null,
"assetSweptSenderAddress": null,
"blockHash": null,
"blockNumber": null,
"blockchain": {
"createdAt": "2024-05-14T17:53:33.106Z",
"derivationPath": "m/44'/60'/0'/0",
"id": "b80d3d5e-16f1-4d99-be5e-6dfcd27f89aa",
"isActive": true,
"isEvmCompatible": true,
"isL2": false,
"logoUrl": "https://res.cloudinary.com/blockradar/image/upload/v1716800080/crypto-assets/bnb-bnb-logo_e4qdyk.png",
"name": "BNB smart chain",
"slug": "bnb-smart-chain",
"symbol": "bnb",
"tokenStandard": "BEP20",
"updatedAt": "2024-11-26T19:04:13.941Z"
},
"chainId": null,
"confirmations": null,
"confirmed": false,
"createdAt": "2025-01-15T21:17:24.013Z",
"currency": null,
"fee": null,
"feeMetadata": null,
"gasFee": null,
"gasPrice": null,
"gasUsed": null,
"hash": null,
"id": "42e94af1-1b8c-47fd-9250-276a3c8a3a71",
"metadata": null,
"network": "testnet",
"note": null,
"reason": "{\"method\":\"transfer\",\"parameters\":[\"0x2455eC6700092991Ce0782365A89d5Cd89c8Fa22\",\"100000\"],\"abi\":{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}}",
"recipientAddress": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
"response": null,
"senderAddress": "0x947514e4B803e312C312da0F1B41fEDdbe15ae7a",
"status": "PENDING",
"tokenAddress": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
"type": "CUSTOM_SMART_CONTRACT",
"updatedAt": "2025-01-15T21:17:24.013Z",
"wallet": {
"address": "0x947514e4B803e312C312da0F1B41fEDdbe15ae7a",
"business": {
"id": "4b96c271-35eb-45e8-b558-6a53f95df601",
"name": "Test One Inc"
},
"createdAt": "2024-08-22T15:29:11.387Z",
"derivationPath": "m/44'/60'/0'/0/0",
"description": "This is BNB smart chain testnet master wallet",
"id": "4465468a-3c36-4536-918a-91d689e18a74",
"isActive": true,
"name": "BNB smart chain Master Wallet",
"network": "testnet",
"status": "ACTIVE",
"updatedAt": "2024-10-30T13:11:56.221Z"
}
},
"message": "Contract write initiated successfully",
"statusCode": 200
}

Batch Operations

This endpoint supports batch operations, allowing you to execute multiple contract write operations in a single API call. This is particularly useful for common patterns like “approve + deposit”.

Batch Request Format

To execute multiple writes, use the calls array:
{
  "calls": [
    {
      "address": "0xTokenContract...",
      "method": "approve",
      "parameters": ["0xSpender...", "1000000000000000000"],
      "abi": [...],
      "reference": "approve-tx",
      "metadata": { "step": "approval" }
    },
    {
      "address": "0xProtocolContract...",
      "method": "deposit",
      "parameters": ["1000000000000000000"],
      "abi": [...],
      "reference": "deposit-tx",
      "metadata": { "step": "deposit" }
    }
  ],
  "code": "123456"
}

Batch Response Format

Batch responses include success and errors arrays:
{
  "message": "Batch contract write initiated successfully",
  "statusCode": 200,
  "data": {
    "success": [
      { "id": "tx-uuid-1", "hash": "0x...", "status": "pending", "reference": "approve-tx" },
      { "id": "tx-uuid-2", "hash": "0x...", "status": "pending", "reference": "deposit-tx" }
    ],
    "errors": []
  }
}

Batch Call Item Schema

ParameterTypeRequiredDescription
addressstringYesSmart contract address
methodstringYesMethod name to call
parametersarrayNoMethod parameters (defaults to [])
abiarrayYesContract ABI
referencestringNoCustom reference for tracking
metadataobjectNoCustom metadata

Error Handling

Batch operations use a partial success pattern:
{
  "data": {
    "success": [...],
    "errors": [
      {
        "index": 2,
        "method": "transfer",
        "error": "Insufficient balance"
      }
    ]
  }
}
  • Operations are executed sequentially
  • A failure in one operation does not stop subsequent operations
  • Check both success and errors arrays to determine overall result

Validation Rules

RuleValue
Max batch size20 operations
Min batch size1 operation
2FA requiredYes

Use Cases

  • Approve + Deposit: Approve token spending then deposit in one call
  • Multi-step transactions: Chain multiple contract calls for DeFi operations
  • Protocol interactions: Execute complex protocol interactions atomically

授权

x-api-key
string
header
必填

路径参数

walletId
string
必填
示例:

"{{walletId}}"

请求体

application/json
calls
object[]
示例:
[
{
"abi": [
{
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"address": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
"method": "transfer",
"parameters": [
"0x2455eC6700092991Ce0782365A89d5Cd89c8Fa22",
"10000"
]
},
{
"abi": [
{
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"address": "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
"method": "transfer",
"parameters": [
"0x2455eC6700092991Ce0782365A89d5Cd89c8Fa22",
"10000"
]
}
]

响应

200 - application/json

Ethereum / Tron / Ethereum (Batch) / Tron (Batch)

data
object
message
string
示例:

"Contract write initiated successfully"

statusCode
number
示例:

200