Skip to content
Cive

signTransaction (Local Account)

Signs a transaction with the Account's private key.

Usage

import {  } from "cive/chains";
import {  } from "cive/utils";
import {  } from "cive/accounts";
 
const  = ("0x...", { : . });
 
const  = await .({
  : 1,
  : ("20"),
  : ("3"),
  : 21000n,
  : 69,
  : .,
});
Output: "0x63667802f876f2458829a2241af62c00008901158e460913d000008252089417f88e30cb8f60dda1c7e3b345f18052b5daa1188080800180c080a0fcbb7b169667d14e3c550a1368bcf567cbe3d111d5da564c015dcc5adaa42220a06d9faad51cd836032c8b43b0faccccca7564fcea8aa8110fb0103953300f0757"

Returns

Hex

The signed transaction.

Parameters

accessList (optional)

The access list.

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

chainId (optional)

  • Type: number

The chain ID.

const  = await .({
  : ., 
});

data (optional)

  • Type: 0x${string}

Transaction data.

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

gas (optional)

  • Type: bigint

The gas limit for the transaction.

const  = await .({
  : .,
  : 21000n, 
});

gasPrice (optional)

  • Type: bigint

gasPrice (optional)

  • Type: bigint

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

const  = await .({
  : .,
  : ("20"), 
});

maxFeePerGas (optional)

  • Type: bigint

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

const  = await .({
  : .,
  : ("20"), 
});

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas (in Drip). Only applies to CIP-1559 Transactions

const  = await .({
  : .,
  : ("20"), 
});

nonce (optional)

  • Type: number

Unique number identifying this transaction.

const  = await .({
  : .,
  : 1, 
});

to (optional)

  • Type: Address

The transaction recipient.

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

type (optional)

  • Type: "legacy" | "eip2930" | "eip1559"

The transaction type.

const  = await .({
  : .,
  : "eip1559", 
});

value (optional)

  • Type: bigint

Value in Drip sent with this transaction.

const  = await .({
  : .,
  : ("2"), 
});

storageLimit (optional)

  • Type: bigint

The storage staking limit.

const  = await .({
  : .,
  : 100n, 
});

epochHeight (optional)

The height that the transaction execution targets.

const  = await .({
  : .,
  : 100n, 
});