I want to create a nomination pool on a substrate based chain, I am using polkadot api, this is what I have managed to write till now
const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');
async function createNominationPool() {
// Define the WebSocket provider (use a Polkadot node endpoint)
const wsProvider = new WsProvider('wss://goldberg.avail.tools/ws');
// Create the API instance
const api = await ApiPromise.create({ provider: wsProvider });
// Create a keyring instance
const keyring = new Keyring({ type: 'sr25519' });
// Add your account to the keyring (replace 'YOUR_SEED_PHRASE' with your seed phrase)
const account = keyring.addFromUri('I cannot tell you this I said NO why you still reading');
// Define the parameters for the nomination pool (adjust as needed)
const initialBalance = 100000000000; // Set the initial balance (in smallest unit, e.g., Plancks for Polkadot)
const rootAccount = account.address; // Set the root account of the pool
const nominatorAccount = account.address; // Set the nominator account of the pool
// Create the nomination pool
const tx = api.tx.nominationPools.create(initialBalance, rootAccount, nominatorAccount, account.address);
// Sign and send the transaction
const hash = await tx.signAndSend(account);
// Log the transaction hash
console.log(`Created nomination pool with transaction hash: ${hash.toString()}`);
}
createNominationPool().catch(console.error);
I tried running it, it gives a runtime WASM error, but doesnt tell me what is really wrong
instruction executed
WASM backtrace:
error while executing at wasm backtrace:
0: 0x2c59af - <unknown>!rust_begin_unwind
1: 0x7775 - <unknown>!core::panicking::panic_fmt::h7a368385936888dc
2: 0x2812fd - <unknown>!TaggedTransactionQueue_validate_transaction: RuntimeApi, Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\nWASM backtrace:\nerror while executing at wasm backtrace:\n 0: 0x2c59af - <unknown>!rust_begin_unwind\n 1: 0x7775 - <unknown>!core::pa…
RpcError: 1002: Verification Error: Runtime error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
WASM backtrace:
error while executing at wasm backtrace:
0: 0x2c59af - <unknown>!rust_begin_unwind
1: 0x7775 - <unknown>!core::panicking::panic_fmt::h7a368385936888dc
2: 0x2812fd - <unknown>!TaggedTransactionQueue_validate_transaction: RuntimeApi, Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed\nWASM backtrace:\nerror while executing at wasm backtrace:\n 0: 0x2c59af - <unknown>!rust_begin_unwind\n 1: 0x7775 - <unknown>!core::pa…
Any help to resolve this error or suggesting a new method to do this would be appreciated, thanks !