Skip to content

Latest commit

 

History

History
177 lines (131 loc) · 3.88 KB

sendUnsignedTransaction.md

File metadata and controls

177 lines (131 loc) · 3.88 KB
head
meta
property content
og:title
sendUnsignedTransaction
meta
name content
description
Executes a transaction regardless of the signature.
meta
property content
og:description
Executes a transaction regardless of the signature.

sendUnsignedTransaction

Executes a transaction regardless of the signature.

Usage

import { testClient } from '.'
 
const hash = await testClient.sendUnsignedTransaction({ // [!code focus:99]
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n
})
// '0x...'

Returns

'0x${string}'[]

The transaction hash.

Parameters

from

  • Type: Address

The Transaction sender.

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n
})

to

  • Type: number

The transaction recipient or contract address.

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n,
  nonce: 69
})

accessList (optional)

  • Type: AccessList

The access list.

const data = await testClient.sendUnsignedTransaction({
  accessList: [ // [!code focus:6]
    {
      address: '0x1',
      storageKeys: ['0x1'],
    },
  ],
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
})

data (optional)

  • Type: 0x${string}

A contract hashed method call with encoded args.

const hash = await testClient.sendUnsignedTransaction({
  data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // [!code focus]
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n
})

gasPrice (optional)

  • Type: bigint

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

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  gasPrice: parseGwei('20'), // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: parseEther('1') 
})

maxFeePerGas (optional)

  • Type: bigint

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

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  maxFeePerGas: parseGwei('20'),  // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: parseEther('1')
})

maxPriorityFeePerGas (optional)

  • Type: bigint

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

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  maxFeePerGas: parseGwei('20'),
  maxPriorityFeePerGas: parseGwei('2'), // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: parseEther('1')
})

nonce (optional)

  • Type: number

Unique number identifying this transaction.

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n,
  nonce: 69 // [!code focus]
})

value (optional)

  • Type: number

Value in wei sent with this transaction.

const hash = await testClient.sendUnsignedTransaction({
  from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: parseEther('1'), // [!code focus]
  nonce: 69
})