Nominate validator(s) for your nomination pool
On-chain name of method: nominationPools_nominate
Parameters
parameter | type | optional | description |
---|---|---|---|
targets | string[] | false | list of validator addresses to nominate |
waitFor | WaitFor | false | wait for block inclusion or finalization |
account | KeyringPair | false | account that will send and sign the transaction |
options | SignerOptions | true | used to overwrite existing signer options |
Returns
On failure, a reason for the failure is returned. On success, the function will return a object of type NominateTxSuccess
.
This object contains the details of the transaction and the nomination pool.
Minimal example
- Inside
your-file-name.ts
, add the following code:
avail-deno
import { Keyring, SDK, WaitFor } from "https://raw.githubusercontent.com/availproject/avail/main/avail-deno/src/sdk.ts";
const providerEndpoint = "wss://turing-rpc.avail.so/ws";
const sdk = await SDK.New(providerEndpoint);
const Alice = 'This is a random seed phrase please do not use it';
const account = new Keyring({ type: "sr25519" }).addFromUri(Alice);
const targets = [
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY",
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty",
];
const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account);
if (result.isErr) {
console.log(result.reason);
Deno.exit(1);
}
console.log(JSON.stringify(result, null, 4));
Deno.exit();
- Run the code using:
deno run --allow-net your-file-name.ts
Sample Response:
{
"isErr": false,
"txData": {
"targets": [
"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY",
"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
]
},
"events": [...],
"txHash": "0x2f81a34f59d36eb7ada96ec1070358043026d7bd7cfb6fa5a532cc474190880b",
"txIndex": 1,
"blockHash": "0x49a57953aa2b2ba508f1c6991515309a0fe89723a79f3831f9a9263ba8c7baa4",
"blockNumber": 4
}