Creating Transactions

Creating a Transaction 

Once your account has some assets, you can create transactions to spend notes and transfer assets.

Creating Raw Transactions 

Raw Transactions contain all the parameters needed to create a transaction on the Iron Fish chain. These include notes to spend, output notes with recipients, assets to mint, assets to burn, and a transaction fee. The Iron Fish RPC server can be used to create raw transactions (see docs here):

async function main(): Promise<void> {
  const sdk = await IronfishSdk.init({ dataDir: '~/.dev0' });
  const client = await sdk.connectRpc();

  const from = '<sending account>';
  const to = '<recipient public address>';
  const assetId = '<optional asset identifier'>;
  const amount = '<amount>';
  const memo = '<memo>';
  const fee = <fee>;
  const expiration = <expiration sequence>;
  const confirmations = <confirmations>;

  const options = {
    account: from,
    outputs: [
      {
        publicAddress: to,
        amount: CurrencyUtils.encode(amount),
        memo,
        assetId,
      },
    ],
    fee: CurrencyUtils.encode(flags.fee),
    expiration,
    confirmations,
  };

  const response = await client.wallet.createTransaction(options);
  console.log(response);
}

Posting Transactions 

After raw transactions are created, they must be posted in order to be added to the mempool and broadcasted to the network (see docs here):

async function main(): Promise<void> {
  const sdk = await IronfishSdk.init({ dataDir: '~/.dev0' });
  const client = await sdk.connectRpc();

  const from = '<sending account>';
  // RawTransactionSerde.serialize(rawTransaction).toString('hex')
  const transaction = '<serialized raw transaction>';
  // Optionally broadcast to network
  const broadcast = true;

  const options = {
    account: from,
    transaction,
    broadcast,
  };

  const response = await client.wallet.postTransaction(options);
  console.log(response);
}

Join our newsletter and stay up to date with privacy and crypto.

Discover our impactful presence — read our blog.

Use

  • Node App
  • Node CLI
  • Mine
  • Block Explorer
  • Ecosystem

Learn

  • Get Started
  • FAQ
  • Whitepaper
  • Tokenomics

Community

  • Foundation
  • Governance
  • Grants
  • Our Community

Developers

  • Documentation
  • Github
Privacy Policy

|

Media Kit

|

Copyright 2024 Iron Fish.