EVM

EVM chains like Ethereum, Polygon, Base, etc support the use of templates to broadcast transactions. Select the following kind:

  • Evm: Use this template if you don't want to worry about gas parameters.

  • Eip1559: Use this template to interact with chains that support the EIP-1559 gas standard.

  • Transaction: broadcasts a fully serialized EVM transaction.

Basic Template

Field
Description
Type - Optional

kind

Evm

String

to

The destination address or target contract.

String (optional)

value

The amount of native tokens to transfer in minimum denomination.

String (optional)

data

ABI encoded function call data in hex format. Can also be the encoded smart contract data when the transaction is a contract deployment.

String (optional)

nonce

The transaction number to guarantee idempotency. If omitted, it will be provided automatically. Note the same nonce can be submitted multiple times with a higher maxFeePerGas to "overwrite" existing transactions in the mempool.

Integer (optional)

externalId

A unique ID from your system. It can be leveraged to be used as an idempotency key (read more here).

String (optional)

{
    "kind": "Evm",
    "to": "0x00fb58432ef9d418bf6688bcf0a226d2fcaa18e2",
    "data": "0x40d097c3000000000000000000000000d2f77f85a50cdd650ca562f3a180284e1d5b4934",
}

EIP-1559 Template

Use this template to adjust the maxFeePerGas and maxPriorityFeePerGas of an EIP-1559 type-2 transaction. Keep in mind that not all EVM compatible chains support this standard.

Field
Description
Type - Optional

kind

Eip1559

String

to

The destination address or target contract.

String (optional)

value

The amount of native tokens to transfer in minimum denomination.

String (optional)

data

ABI encoded function call data in hex format. Can also be the encoded smart contract data when the transaction is a contract deployment.

String (optional)

nonce

The transaction number to guarantee idempotency. If omitted, it will be provided automatically. Note the same nonce can be submitted multiple times with a higher maxFeePerGas to "overwrite" existing transactions in the mempool.

Integer (optional)

gasLimit

The maximum amount of gas that can be spent for executing the transaction. If omitted, it will be calculated automatically.

String (optional)

maxPriorityFeePerGas

The maximum amount of gas to be included as a tip to the validator. If omitted, it will be calculated automatically.

String (optional)

maxFeePerGas

The maximum amount for gas willing to be paid for the transaction. If omitted, it will be calculated automatically.

String (optional)

externalId

A unique ID from your system. It can be leveraged to be used as an idempotency key (read more here).

String (optional)

{
    "kind": "Eip1559",
    "to": "0x00fb58432ef9d418bf6688bcf0a226d2fcaa18e2",
    "data": "0x40d097c3000000000000000000000000d2f77f85a50cdd650ca562f3a180284e1d5b4934",
    "maxFeePerGas": "1626000000000",
    "maxPriorityFeePerGas": "1332000000000"
}

Transaction

Signs an unsigned transaction and broadcasts it to chain.

Property
Description
Type - Optional

kind

Transaction

String

transaction

The unsigned hex encoded transaction as shown below.

String

externalId

A unique ID from your system. It can be leveraged to be used as an idempotency key. (read more here)

String (optional)

{
  "kind": "Transaction",
  "transaction": "0x02e783aa36a71503850d40e49def82520894e5a2ebc128e262ab1e3bd02bffbe16911adfbffb0180c0"
}

Typescript Example with Ethers

First install the Ethers JS. You can find the full documentation here: https://docs.ethers.org/v6/

Here a code sample to broadcast a transaction via the Dfns TypeScript SDK:

import { parseUnits, Transaction } from 'ethers'

const walletId = 'wa-6lbfv-9esgj-xxxxxxxxxxxxxxxx'

const transaction = Transaction.from({
  to: '0xa238b6008Bc2FBd9E386A5d4784511980cE504Cd',
  value: '1',
  gasLimit: '21000',
  maxPriorityFeePerGas: parseUnits('5', 'gwei'),
  maxFeePerGas: parseUnits('20', 'gwei'),
  nonce: 3,
  type: 2,
  chainId: 11155111,
})

const res = await dfnsClient.wallets.broadcastTransaction({
  walletId,
  body: { kind: 'Transaction', transaction: transaction.unsignedSerialized },
})

User Operations

Signs one or more user operations and broadcasts to chain using a sponsored transaction. Used for invoking arbitrary smart contract calls, including batch operations, with a fee sponsor.

Property
Description
Type - Optional

kind

UserOperations

String

userOperations

One or more user operations. See format below.

Array<UserOperation>

feeSponsorId

A fee sponsor id to sponsor the transaction fee by another wallet. (read more here)

String

externalId

A unique ID from your system. It can be leveraged to be used as an idempotency key. (read more here)

String (optional)

UserOperation

Property
Description
Type - Optional

to

The destination address or target contract.

String

value

The amount of native tokens to transfer in minimum denomination.

String (optional)

data

ABI encoded function call data in hex format.

String (optional)

{
  "kind": "UserOperations",
  "userOperations": [
    {
      "to": "0xd964d741998edc275f3800eed113378a391951d9",
      "data": "0xa9059cbb000000000000000000000000d964d741998edc275f3800eed113378a391951d90000000000000000000000000000000000000000000000000000000000000001"
    }
  ],
  "feeSponsorId": "fs-5ercu-e9r9u-xxxxxxxxxxxxxxxx"
}

Last updated