Class Transaction

Hierarchy

  • Transaction

Constructors

Properties

Transaction options

provider?: Provider

Provider to connect with the blockchain

Signer interacting with the smart contracts

transaction: TransactionJson

Transaction

waitFunction?: WaitFunction

Function to wait for the transaction to be mined

Methods

  • Function to push an operation to the transaction. It can be created in several ways. Example:

    Example

    const koin = new Contract({
    id: "15DJN4a8SgrbGhhGksSBASiSYjGnMU8dGL",
    abi: utils.tokenAbi,
    }).functions;
    const signer = Signer.fromSeed("my seed");
    const provider = new Provider(["https://api.koinos.io"]);
    signer.provider = provider;
    const tx = new Transaction({ signer });

    // method 1
    await tx.pushOperation(koin.transfer, {
    from: "1NRYHBYr9qxYQAeVqfdSvyjJemRQ4qD3Mt",
    to: "13UdKjYuzfBYbB6bGLQkUN9DJRFPCmG1mU",
    value: "1000",
    });

    // method 2
    await tx.pushOperation(
    koin.transfer({
    from: "1NRYHBYr9qxYQAeVqfdSvyjJemRQ4qD3Mt",
    to: "13UdKjYuzfBYbB6bGLQkUN9DJRFPCmG1mU",
    value: "1000",
    },{
    onlyOperation: true,
    })
    );

    // method 3
    await tx.pushOperation(
    await koin.transfer({
    from: "1NRYHBYr9qxYQAeVqfdSvyjJemRQ4qD3Mt",
    to: "13UdKjYuzfBYbB6bGLQkUN9DJRFPCmG1mU",
    value: "1000",
    },{
    onlyOperation: true,
    })
    );

    // method 4
    const { operation } = await koin.transfer({
    from: "1NRYHBYr9qxYQAeVqfdSvyjJemRQ4qD3Mt",
    to: "13UdKjYuzfBYbB6bGLQkUN9DJRFPCmG1mU",
    value: "1000",
    },{
    onlyOperation: true,
    });
    await tx.pushOperation(operation)

    Parameters

    Returns Promise<void>

  • Parameters

    • Optional type: "byBlock" | "byTransactionId"
    • Optional timeout: number

    Returns Promise<{ blockId: string; blockNumber?: number }>

  • Function to prepare a transaction

    Returns

    A prepared transaction.

    Parameters

    • tx: TransactionJson

      Do not set the nonce to get it from the blockchain using the provider. The rc_limit is 1e8 by default.

    • Optional provider: Provider

      Provider

    • Optional payer: string

      payer to be used in case it is not defined in the transaction

    Returns Promise<TransactionJson>

Generated using TypeDoc