createWallet(sender, currency, amount, ?:seed, ?:weight)

Feature

Return a key pair and a raw operation to transfer the native token to the newly generated account.

Used to create a single sig account. Note : Like other blockchains, newly created accounts are recorded in blocks when the first transaction occurs. This function returns the raw operation to initiate the first transaction (native token transfer).

Parameters

string sender address, string currencyID, int | string amount, null | string seed (optional), null | int | string weight (optional, default = 100)

Return Value

object wallet info { wallet : object key pair, operation : object currency transfer operation }

example

// Address which send the token to the newly created account
const sender = "0x15838b16912F79AA7aDB45258d146E488A971869fca";
// ID of native token
const currencyID = "MIT";
// Amount of token to transfer (units of 10^-18)
const amount = 10;
// seed for generation of new account (optional)
const seed = "The MITUM blockchain is evolving every day.";;

const { wallet, operation } = mitum.account.createWallet(sender, currencyID, amount, seed);
console.log(wallet);
console.log(operation);

// newly calculated keypair
{
  privatekey: '4d4c7a3632526575aa5e56c6ee64dc174b67a7edc155ebdb63c333180898f1e6fpr',
  publickey: '029187852a565afa52cc7def7b3d86624a042d9138522a729fffc082e080aa6297fpu',
  address: '0x76107260461B2Cb63D78e8E7957feFa3E72f6Ac2fca'
}
// raw operation to transfer native token to newly created account from sender
Operation {
  id: 'mitum',
  fact: TransferFact {
    hint: Hint { s: 'mitum-currency-transfer-operation-fact' },
    token: Token { s: '2024-05-20 07:11:04.936 +0000 UTC' },
    _hash: <Buffer f8 e1 b4 2c 61 e2 34 b1 ce 6d e1 cf d4 86 27 58 db 2d 4a 0d 74 d6 3b 64 57 72 59 bd 2f bd f9 99>,
    sender: Address {
      s: '0x15838b16912F79AA7aDB45258d146E488A971869fca',
      type: 'mitum'
    },
    items: [ [TransferItem] ]
  },
  hint: Hint { s: 'mitum-currency-transfer-operation' },
  _factSigns: [],
  _hash: <Buffer >
}

Last updated