createAccount(sender, key, currency, amount)

Feature

Return a raw operation for creating a new contract-account via a given public key. 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). The owner of the newly created contract-account is sender. Since it's a CA, the public keys are generally useless. (The public key can be used for account lookup)

Parameters

string sender address, string receiver public key, string currency ID, int | string amount

Return Value

object create contract account operation

example

const senderAddress = "0x78f707a5CB15924b5edf7E45cD8df06b577984F7fca";
const receiverPublickey = "029187852a565afa52cc7def7b3d86624a042d9138522a729fffc082e080aa6297fpu";
const currencyID = "MCC";
const amount = 10000;

const createOperation = mitum.contract.createAccount(
    senderAddress,
    receiverPublickey,
    currencyID,
    amount
);
console.log(createOperation);

// output
Operation {
  id: 'mitum',
  fact: CreateContractAccountFact {
    hint: Hint { s: 'mitum-currency-create-contract-account-operation-fact' },
    token: Token { s: '2023-09-26 08:38:39.692 +0000 UTC' },
    _hash: <Buffer 04 b7 c8 a6 81 b6 22 4e db 03 33 2c fa 8b bc 91 ea 4c 53 b5 1e 13 1b 2f ee a3 bf c2 04 60 a2 94>,
    sender: Address {
      s: '0x78f707a5CB15924b5edf7E45cD8df06b577984F7fca',
      type: 'mitum'
    },
    items: [ [CreateContractAccountItem] ]
  },
  hint: Hint { s: 'mitum-currency-create-contract-account-operation' },
  _factSigns: [],
  _hash: <Buffer >
}

Last updated