Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. const registrations_count = 3;
  2. const nodeUrl = "wss://rpc-private-a-vip-catnet.iov.one";
  3. const mnemonic = "twin document gold guide asset false rival rib civil squeeze they upper";
  4.  
  5. const profile = new UserProfile();
  6. const signer = new MultiChainSigner(profile);
  7. const { connection } = await signer.addChain(createBnsConnector(nodeUrl));
  8. const chainId = connection.chainId();
  9. const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));
  10.  
  11. // any identity that can pay the fees
  12. const friend = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0))
  13. const friendAddress = signer.identityToAddress(friend);
  14. console.log("Address", friendAddress);
  15.  
  16. for (let i = 0; i < registrations_count; i++) {
  17. const username = `testuser_${Math.random()}*iov`;
  18. console.log("Registering", username);
  19. const tx = await connection.withDefaultFee<RegisterUsernameTx & WithCreator>({
  20. kind: "bns/register_username",
  21. creator: friend,
  22. username: username,
  23. targets: [],
  24. });
  25.  
  26. const postResult = await signer.signAndPost(tx);
  27. const blockInfo = await postResult.blockInfo.waitFor(info => !isBlockInfoPending(info));
  28. if (!isBlockInfoSucceeded(blockInfo)) {
  29. throw new Error("Transaction failed");
  30. }
  31.  
  32. console.log("Successfully registered", username);
  33. console.log("Chain height is now", await connection.height());
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement