Overview
This node adds an access key to a NEAR blockchain account. It is useful for managing permissions on NEAR smart contracts by associating new public keys with specific contract accounts and optionally restricting the allowed method calls. This enables delegated access or automated interactions with contracts without sharing full account credentials.
Common scenarios include:
- Granting limited access to a contract for a third-party service or dApp.
- Automating contract interactions by adding keys that can call only certain methods.
- Managing multiple keys for different purposes on a single NEAR account.
Example: Adding a public key that can only call specified methods on a deployed contract, enabling secure and controlled contract interaction.
Properties
| Name | Meaning |
|---|---|
| Network ID | The NEAR network to connect to. Options: "mainnet", "testnet". |
| Private Key to Sign | The private key of the signer account used to authorize adding the new access key (format: ed25519:...). |
| Signer Account ID | The NEAR account ID that will sign the transaction to add the key (e.g., example.near). |
| Public Key to Add | The public key to associate with the contract or account (format: ed25519:...). |
| Contract Account ID | The NEAR account where the contract is deployed. Optional; if omitted, the key is added to the signer account. |
| Method Names as JSON | JSON array of method names allowed to be called by this key. Pass null for no method restrictions, or empty array/string for all methods. |
| Attached NEAR Amount | Amount in yoctoⓃ (1e-24 NEAR) attached to the function call, sent to the contract during key addition. |
Output
The node outputs the result of the addKey operation from the NEAR API in the json.result field. This typically includes transaction details confirming the successful addition of the access key.
No binary data output is produced.
Dependencies
- Requires connection to the NEAR blockchain network (mainnet or testnet).
- Needs a valid private key credential for signing transactions.
- Uses the
near-api-jslibrary internally to interact with NEAR. - No additional environment variables are required beyond the provided input properties.
Troubleshooting
- Invalid Private Key: If the private key format is incorrect or does not correspond to the signer account, the transaction will fail. Ensure the private key is correct and properly formatted.
- Incorrect Network ID: Using a network ID that does not match the intended NEAR network will cause connection errors. Verify the network ID matches the target network.
- Malformed JSON in Method Names: The
methodNamesproperty must be valid JSON if provided. Invalid JSON will cause parsing errors. Usenull,[], or a valid JSON array string. - Insufficient Permissions: The signer account must have permission to add keys. Errors related to authorization indicate insufficient account privileges.
- Amount Format: The attached amount must be a numeric string representing yoctoⓃ. Non-numeric or improperly formatted values will cause errors.
If the node is set to continue on failure, errors will be included in the output per item; otherwise, execution stops at the first error.