Skip to content

Improve docs TransactionBuilder for lockingBytecode argument for output to: #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mr-zwets opened this issue Apr 22, 2025 · 0 comments
Labels
documentation Relates to documentation

Comments

@mr-zwets
Copy link
Member

Currently from the docs of the TransactionBuilder API it is not fully clear you can also provide lockingBytecode for the output to:

but this might play an increasingly important role in the future with the P2S CHIP

addOutput() & addOutputs()

transactionBuilder.addOutput(output: Output): this
transactionBuilder.addOutputs(outputs: Output[]): this

Adds a single output or a list of outputs to the transaction.

interface Output {
  to: string | Uint8Array;
  amount: bigint;
  token?: TokenDetails;
}

interface TokenDetails {
  amount: bigint;
  category: string;
  nft?: {
    capability: 'none' | 'mutable' | 'minting';
    commitment: string;
  };
}

Example

import { aliceAddress, bobAddress, transactionBuilder, tokenCategory } from './somewhere.js';

transactionBuilder.addOutput({
  to: aliceAddress,
  amount: 100_000n,
  token: {
    amount: 1000n,
    category: tokenCategory,
  }
});

transactionBuilder.addOutputs([
  { to: aliceAddress, amount: 50_000n },
  { to: bobAddress, amount: 50_000n },
]);
@mr-zwets mr-zwets added the documentation Relates to documentation label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to documentation
Projects
None yet
Development

No branches or pull requests

1 participant