API
@joyid/evm
sendTransaction

sendTransaction

Signs and send tx, returning tx hash.

Note that gasLimit, gasPrice, maxPriorityFeePerGas, maxFeePerGas is a string that can be passed to BigInt (opens in a new tab). eg.

// ✅ valid
const gasPriceString = "9007199254740991"
// ✅ valid
const gasPriceHex = "0x1fffffffffffff"
// ✅ valid
const gasPriceOctal = "0o377777777777777777"
// ❌ invalid
const gasPriceNumber = 9007199254740991
// ❌ invalid
const gasPriceBigInt = 9007199254740991n
// ❌ invalid
const gasPriceBigInt2 = BigInt(9007199254740991)

Types

function signTransaction(tx: TransactionRequest, signerAddress?: string): Promise<string>
 
interface TransactionRequest {
  maxPriorityFeePerGas?: string
  maxFeePerGas?: string
 
  to?: string
  from?: string
  nonce?: number
 
  gasLimit?: string
  gasPrice?: string
 
  data?: string
  value?: string
  chainId?: number
 
  accessList?: AccessList
 
  customData?: Record<string, any>
  ccipReadEnabled?: boolean
}
 
type AccessList = Array<{ address: EthAddress; storageKeys: Array<string> }>

Example

import { sendTransaction } from '@joyid/evm'
 
async function signTransactionOnClick(tx) {
  const txhash = await sendTransaction(tx)
  console.log(txhash)
}