Overview
This n8n node, Write Contract Call, enables users to send write (state-changing) contract calls to the NEAR Protocol blockchain. It is designed for scenarios where you need to interact with smart contracts on NEAR—such as updating contract state, invoking methods that modify data, or triggering on-chain actions.
Common use cases:
- Setting or updating values in a NEAR smart contract (e.g., storing user preferences, updating balances).
- Triggering contract-based workflows from within an n8n automation.
- Integrating NEAR blockchain operations into business processes, such as logging transactions or automating decentralized application (dApp) interactions.
Practical example:
You could use this node to call a method like set_value_by_key
on a NEAR smart contract, passing in a JSON object as arguments to update a value stored on-chain.
Properties
Name | Type | Meaning |
---|---|---|
Network ID | String | The NEAR network to connect to (e.g., "mainnet" or "testnet"). |
Private Key | String | The private key of the signer account, used to authorize and sign the transaction. |
Signer Account ID | String | The NEAR account ID that will sign and send the contract call. |
Contract Account ID | String | The NEAR account ID of the target smart contract. |
Method Name | String | The name of the contract method to invoke (must be a write method). |
Arguments JSON | String | A JSON string representing the arguments to pass to the contract method. |
Output
The node outputs an array of items, each containing a json
field with the following structure:
{
"result": { /* NEAR functionCall result object */ }
}
- result: Contains the response from the NEAR blockchain after executing the contract method. This typically includes transaction details, status, and any return values from the contract method.
If an error occurs and "Continue On Fail" is enabled, the output item will also include:
{
"json": { /* original input json */ },
"error": { /* error object */ },
"pairedItem": <item index>
}
Note: This node does not output binary data.
Dependencies
- External Services: Requires access to the NEAR blockchain (either mainnet or testnet).
- API Keys / Credentials: Needs the private key of the NEAR account performing the contract call.
- n8n Configuration: No special environment variables required, but internet access to NEAR RPC endpoints is necessary.
Troubleshooting
Common Issues:
- Invalid Private Key: If the provided private key is incorrect or malformed, the node will throw an authentication error.
- Incorrect Network ID: Using an unsupported or misspelled network ID will cause connection failures.
- Malformed Arguments JSON: If the "Arguments JSON" property is not valid JSON, parsing will fail.
- Contract/Method Not Found: If the contract account ID or method name is incorrect, the NEAR API will return an error.
Error Handling:
- If "Continue On Fail" is enabled, errors are attached to the output item under the
error
field. - Otherwise, execution stops and the error is thrown. Error messages may include context such as the item index.
How to resolve:
- Double-check all account IDs, private keys, and method names.
- Ensure the "Arguments JSON" is properly formatted.
- Verify network connectivity to NEAR endpoints.