Skip to main content

Send a Transaction

tip

Before diving into this tutorial, please ensure you already have an asset wallet with some ETH(SEPOLIA)_ETHEREUM_SEPOLIA tokens. You can also refer to Create a Wallet to create your own wallets.

This tutorial consists of an example of a transfer task. Check out Transaction Task to learn more.

In this tutorial, you will learn how to:

  1. Create a transfer task
  2. Approve and sign
  3. Track transaction progress and status

Create a Transfer Task

Consider a transaction scenario in which ETH(SEPOLIA)_ETHEREUM_SEPOLIA tokens are sent from an asset wallet whose accountKey is account4b8d2c00520646c8862b68420aa1bc55 to an external unknown address 0x9437A77E6BE3a7Bf5F3cfE611BfCd1Fd30BF95f5 with a transfer amount of 0.1 ETH.

Request Parameters

tip

This example uses a transaction fee tier, which is for setting the txFeeLevel parameter. For more information about transaction fees, please refer to Estimate Transaction Fee.

interface CreateTransactionRequest {
customerRefId: string;
coinKey: string;
txFeeLevel?: string;
feeRateDto?: {
feeRate?: string;
gasLimit?: string;
maxPriorityFee?: string;
maxFee?: string
};
txAmount: string;
sourceAccountKey: string;
sourceAccountType: string;
destinationAccountKey?: string;
destinationAccountType: string;
destinationAddress: string;
}

const request: CreateTransactionRequest = {
sourceAccountKey: 'account4b8d2c00520646c8862b68420aa1bc55',
sourceAccountType: 'VAULT_ACCOUNT',
destinationAccountType: 'ONE_TIME_ADDRESS',
destinationAddress: '0x9437A77E6BE3a7Bf5F3cfE611BfCd1Fd30BF95f5',
coinKey: 'ETH(SEPOLIA)_ETHEREUM_SEPOLIA',
txAmount: '0.1',
txFeeLevel: 'MIDDLE',
customerRefId: uuid(),
};

Request the Interface

interface CreateTransactionResponse {
txKey: string;
}

const response = await client.doRequest<CreateTransactionRequest, CreateTransactionResponse>('/v2/transactions/create', request);

Example Response Data

tip

txKey is a unique identifier for a transaction.

{
"txKey": "tx46461daa9b7a4612abce99e7ce598844"
}

Approve and Sign

Once a transaction task has been created, the system will proceed with either manual or automated approval via the API Co-Signer based on your policies.

You will receive a push notification on the Safeheron App of the created transaction which will be displayed in the "Pending" with "Pending Approval" status. When the approval completes, the last approver will sign the transaction on Safeheron App.

Transaction Progress and Status

The created transaction task will undergo approval, signing, broadcasting, on-chain confirmation, etc. You can track the status of all transactions here. We also suggest using Webhook to acquire time-sensitive status updates and signature results.

tip

You can track transaction tasks with webhook by configuring the Webhook URL in Settings -> API on Safeheron Web Console.

For Your Reference

The code described in this tutorial is open-sourced on Safeheron's GitHub. For the full source code:

At this point, you have learned how to create a transfer task. You can learn more about creating other types of transactions through the API.