Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const registrations_count = 3;
- const nodeUrl = "wss://rpc-private-a-vip-catnet.iov.one";
- const mnemonic = "twin document gold guide asset false rival rib civil squeeze they upper";
- const profile = new UserProfile();
- const signer = new MultiChainSigner(profile);
- const { connection } = await signer.addChain(createBnsConnector(nodeUrl));
- const chainId = connection.chainId();
- const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));
- // any identity that can pay the fees
- const friend = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0))
- const friendAddress = signer.identityToAddress(friend);
- console.log("Address", friendAddress);
- for (let i = 0; i < registrations_count; i++) {
- const username = `testuser_${Math.random()}*iov`;
- console.log("Registering", username);
- const tx = await connection.withDefaultFee<RegisterUsernameTx & WithCreator>({
- kind: "bns/register_username",
- creator: friend,
- username: username,
- targets: [],
- });
- const postResult = await signer.signAndPost(tx);
- const blockInfo = await postResult.blockInfo.waitFor(info => !isBlockInfoPending(info));
- if (!isBlockInfoSucceeded(blockInfo)) {
- throw new Error("Transaction failed");
- }
- console.log("Successfully registered", username);
- console.log("Chain height is now", await connection.height());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement