Send Transaction
This method allows you to send a custom transaction on a blockchain network.
Method Signature
async sendTransaction(config: SendTransactionConfig): Promise<TransactionReceipt>
Parameters
config
: SendTransactionConfig
- An object with the following properties:
network
:Network
(required) - The network used for transactions.transaction
:object
(required) - The raw transaction data, containing:from
:string
(required) - The address of the sender.to
:string
(required) - The address of the recipient.data
:string
(required) - The data payload of the transaction.value
:string
(optional) - The amount of native currency to send with the transaction.gasPrice
:string
(optional) - Gas price in Wei (this will be calculated automatically if not provided).gasLimit
:string
(optional) - Gas limit for the transaction (this will be calculated automatically if not provided).nonce
:string
(optional) - The number used once to prevent duplicate transactions (this will be calculated automatically if not provided).maxFeePerGas
:string
(optional) - Maximum fee per gas provided (this will be calculated automatically if not provided).maxPriorityFeePerGas
:string
(optional) - Maximum priority fee per gas you are willing to pay, this only used in EIP1559 support blockchain.
Returns
Promise<TransactionReceipt>
- An object containing the transaction receipt data.
Example Usage
const receipt = await sdk.wallet.sendTransaction({
network: Network.ETHEREUM,
transaction: {
from: '0x1234567890123456789012345678901234567890',
to: '0x0987654321098765432109876543210987654321',
data: '0x',
value: '0x0',
gasPrice: '0x09184e72a000',
gasLimit: '0x5208'
}
});
console.log(receipt);
Response Example
{
"txReceipt": {
"_type": "TransactionReceipt",
"accessList": null,
"blockNumber": null,
"blockHash": null,
"chainId": "1",
"data": "0x",
"from": "0x5B3A69CD0984c8621c75c54aa4dCA89e382523A9",
"gasLimit": "21000",
"gasPrice": "123278603083",
"hash": "0x94cb07276ea513abde5d9c8f1bca1986822e9ed176190dd91d29a5c99ed62075",
"maxFeePerGas": null,
"maxPriorityFeePerGas": null,
"nonce": 4,
"signature": {
"_type": "signature",
"networkV": "230",
"r": "0x862636e954a2f904290499eb206a0b959f2aa6383c4ed66427b057db791fc047",
"s": "0x674f31a31e935265964d450d070de48a41d914194ff37aa3f22a98c2c2a31ec1",
"v": 28
},
"to": "0x5B3A69CD0984c8621c75c54aa4dCA89e382523A9",
"type": 0,
"value": "0"
}
}
ℹ️
The response is an object containing the transaction receipt data, including details such as the transaction hash, gas used, and block information.
Additional Information
- This method requires a valid wallet token in the SDK configuration.
- The
transaction
object should contain the raw transaction data you want to send. - Optional parameters like
nonce
,gasPrice
, andgasLimit
will be automatically calculated if not provided. - For EIP1559 compatible networks, you can specify
maxFeePerGas
andmaxPriorityFeePerGas
. - All numeric values in the transaction object should be provided as hexadecimal strings (e.g., '0x5208' for gasLimit).
For more information, see the Xellar Send Transaction API Documentation (opens in a new tab).