Skip to content
Cive

prepareTransactionRequest

Prepares a transaction request for signing by populating a nonce, gas limit, fee values, and a transaction type.

Usage

import {  } from "cive";
import { ,  } from "./config";
 
const  = await .({
  ,
  : "cfx:...",
  : ("1"),
});

Returns

TransactionRequest

The transaction request

Parameters

account

  • Type: Account | Address

The Account to send the transaction from.

const  = await .({
  : , // or "cfx:...",
  : "cfx:...",
  : 1000000000000000000n,
});

to

  • Type: Address

The transaction recipient or contract address.

const  = await .({
  ,
  : "cfx:...", 
  : 1000000000000000000n,
  : 1,
});

accessList (optional)

The access list.

const  = await .({
  : [
    {
      : "cfx:...",
      : ["0x1"],
    },
  ],
  ,
  : "cfx:...",
});

data (optional)

  • Type: 0x${string}

A contract hashed method call with encoded args.

const  = await .({
  : "0x...", 
  ,
  : "cfx:...",
  : 1000000000000000000n,
});

gasPrice (optional)

  • Type: bigint

The price (in drip) to pay per gas. Only applies to Legacy Transactions.

import { ,  } from "cive";
 
const  = await .({
  ,
  : ("20"), 
  : "cfx:...",
  : ("1"),
});

maxFeePerGas (optional)

  • Type: bigint

Total fee per gas (in drip), inclusive of maxPriorityFeePerGas. Only applies to EIP-1559 Transactions

import { ,  } from "cive";
 
const  = await .({
  ,
  : ("20"), 
  : "cfx:...",
  : ("1"),
});

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions

import { ,  } from "cive";
 
const  = await .({
  ,
  : ("20"),
  : ("2"), 
  : "cfx:...",
  : ("1"),
});

nonce (optional)

  • Type: number

Unique number identifying this transaction.

const  = await .({
  ,
  : "cfx:...",
  : 1000000000000000000n,
  : 6, 
});

parameters (optional)

  • Type: ("fees" | "gas" | "nonce" | "type" | "epochHeight" |"storageLimit")[]
  • Default: ["fees", "gas", "nonce", "type", "epochHeight", "storageLimit"]

Parameters to prepare.

For instance, if ["gas", "nonce"] is provided, then only the gas and nonce parameters will be prepared.

const  = await .({
  ,
  : "cfx:...",
  : 1000000000000000000n,
  : 1, 
});

value (optional)

  • Type: bigint

Value in wei sent with this transaction.

import {  } from "cive";
 
const  = await .({
  ,
  : "cfx:...",
  : ("1"), 
  : 69,
});

epochHeight (optional)

  • Type: bigint
import {  } from "cive";
 
const  = await .({
  ,
  : "cfx:...",
  : 11n, 
});

storageLimit (optional)

  • Type: bigint
import {  } from "cive";
 
const  = await .({
  ,
  : "cfx:...",
  : 11n, 
});