Register Node
Register a light node to participate on the network
await api.send.registerNode(
NODE_ID,
NODE_OWNER_ADDRESS,
NODE_SIGNING_PUBLIC_KEY
);
important
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.io";
// A function to sign
const signerFunc = {
sign: async (data, signerAddress) => await signData(data, signerAddress),
};
const multiUserOptions = {
setupMode: SetupMode.MultiUser,
signingMode: SigningMode.RemoteSigner,
hasPayer: true,
defaultLogLevel: "error",
signerFunc,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, singleUserOptions);
// The address or public key of the node
const NODE_ID = "5DA...gxV";
// The address or public key of the node owner
const NODE_OWNER_ADDRESS = "0x2a...b0e";
// The public key (32 bytes hex value) of the generated signing key
const NODE_SIGNING_PUBLIC_KEY = "0xca04d5bddcd9c5af2e...f3201ba8abc3fbed31f";
// The privileged address that can register nodes
const NODE_REGISTRAR_ADDRESS = "5Dh...GxV";
async function main() {
await avnSdk.init();
const api = await avnSdk.apis(NODE_REGISTRAR_ADDRESS);
let result = await api.send.registerNode(
NODE_ID,
NODE_OWNER_ADDRESS,
NODE_SIGNING_PUBLIC_KEY,
);
// Returns a request id
console.log(result);
}
(async () => {
await main();
})();
Response: f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
REQUEST
POST https://AVN_GATEWAY_URL/send
HEADERS
Content-Type: application/json Authorization': bearer <awtToken>
REQUEST PARAMS
- relayer [required] - a string representing the relayer's SS58 address
- user [required] - a string representing the node registrar's SS58 address
- payer [required] - a string representing the payer's SS58 address
- nodeId [required] - a string representing the node's public address
- nodeOwner [required] - a string representing the node owner's public address
- nodeSigningKey [required] - a hex string (without the 0x) representing the node's public signing key
- blockNumber [required] - a number representing the current finalised block number of the chain
- proxySignature [required] - a proof signed by the user allowing the transaction to be proxied
- feePaymentSignature [required] - a proof signed by the payer allowing the relayer fees to be paid
- paymentNonce [required] - string integer value of the current payment nonce of the payer
JSON-RPC Example
curl https://AVN-API-URL/send \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"proxyRegisterNode", "params":{"relayer":"5FbUQ2kJWLo...Gyu6UoZaryTh", "user":"5DAgxVxKmn...rSVJDdMr", "payer":"5DAgxVxKmn...rSVJDdMr", nodeId: "5FqDfHoHrF8rJhSES6A58irFNvKYYmByC1X8ZZRNPSQgAwfr", "nodeOwner": "5HgZKQZMkNhhH5gXjnfsktiZo91kyZ1D3kSB59c698XxUMaS", "nodeSigningKey": "f88541cab3dbf94df57c3c4954cfb1303be5c4fde1fdf52bfd4d4def7852bc57", "blockNumber": 123, "proxySignature":"0x883e4300581d...4d4500d1aab8b7832076484d967ca01c96e7ab6d20903145c9efebac38ed521f30fe52da2e27beecf08f", "feePaymentSignature":"0x7cff997be6fb...62bf6617a4c23319f666dfc2bb9e9a365ffd67ab279d980a0139fa6ce0165cdd76aaf555e7a1ba80", "paymentNonce":"199"}, "id":1}'
note
result - a request ID that can be queried for the transaction's status.
{
"jsonrpc": "2.0",
"id": 1,
"result": "8b62441c-e032-46e3-bd1d-0f8a0a764442"
}
You have now successfully submitted a transaction to register a node.
tip
You can query the state of your transaction here using the returned result.