Sign RAW Transactions
This page describes how to sign raw transactions and submit them yourself to the blockchain.
How to sign RAW transactions?
The Venly Wallet-API takes care of the complete blockchain management to execute transactions (signing, submitting, and follow-up).
We advise only using the regular transaction API (
POST /transactions/execute)
to perform blockchain operations. Only use the below-described functionality if you have a deep understanding how blockchain technology works.
Context
In some cases, you may want to submit transactions yourself to the blockchain. For example, you may want to submit transactions through your own blockchain node when you run your own node.
To be able to do this, you will need to encode the RAW transaction data and sign this data with the respective Venly-wallet. The resulting signature can then be used to submit the transaction to the blockchain.
This page shows examples of retrieving the signature for different chains.
Request Endpoint: reference
POST /api/signatures
Request Body:
The body for the endpoint depends on which chain the transaction is for. First, there is a set of common fields and then there are some custom fields per (type of) chain.
Note that there is a difference between creating a transaction for a native token transfer or calling a contract:
- For native token transactions, the provided API can be used as described, without providing a
data
element. No encoded function is needed.- For calling contracts or doing (ERC-20, ERC-721, or ERC-1155) token transactions, which are basically contract calls as well (
safeTransferFrom
function), you'll need to construct the (transaction-)data yourself.
There are a number of libraries that allow you to build the encoded transaction data (e.g. web3j
for Java, web3py
for Python, etc.)
In web3j
, building the encoded function looks something like this:
List inputParams = new ArrayList();
List outputParams = new ArrayList();
Function function = new Function("fuctionName", inputParams, outputParams);
String encodedFunction = FunctionEncoder.encode(function)
The encodedFunction
is what needs to be passed as data
in the Request Body.
Types
ETHEREUM_TRANSACTION
BSC_TRANSACTION
AVAC_TRANSACTION
MATIC_TRANSACTION
GOCHAIN_TRANSACTION
VECHAIN_TRANSACTION
BITCOIN_TRANSACTION
LITECOIN_TRANSACTION
AETERNITY_TRANSACTION
NEO_NATIVE_TRANSACTION
NEO_GAS_TRANSACTION
HEDERA_TRANSACTION
Common Fields
Parameter | Param Type | Value | Description | Example Value |
---|---|---|---|---|
Signing-Method | Header | id:value | id : This is the ID of the signing methodvalue : This is the value of the signing method | 756ae7a7-3713-43ee-9936-0dff50306488:123456 |
Field | Type | Description | Mandatory |
---|---|---|---|
pincode (Deprecated) | String | The PIN code of the wallet that needs to sign for this request. | ❌ |
walletId | String | The ID of the wallet you want to use to sign the transaction. | ✅ |
submit | boolean | Whether or not you also immediately want to submit the transaction to the blockchain. | ✅ |
type | Type | The type of transaction you are trying to sign.See types for the possible values. | ✅ |
{
walletId!: string,
submit!: boolean,
type!: Type
}
Custom Fields
EVM based chains
This applies to the following types ETHEREUM_TRANSACTION
, BSC_TRANSACTION
, AVAC_TRANSACTION
, MATIC_TRANSACTION
and GOCHAIN_TRANSACTION
.
{
walletId!: string,
submit!: boolean,
type!: Type,
to!: string,
value?: number,
data?: string,
gas!: number,
gasPrice!: number,
nonce!: number
}
Field | Type | Description | Mandatory? |
---|---|---|---|
to | String | The destination of the transaction. | ✅ |
value | number | The amount of native currency in wei (e.g. Ether, Matic, BNB) you want to include in the transaction. | ❌ |
data | String | The data you want to include in the transaction (if any). Here you can for example add an encoded contract call (encodedFunction ). | ❌ |
gas | number | The max amount of gas (gas limit) this transaction is allowed to use. | ✅ |
gasPrice | number | The price in wei that you want to pay for one amount of gas. | ✅ |
nonce | number | The nonce (sequence) of the transaction. | ✅ |
If you want a prediction of the
gas
/gasPrice
and the nextnonce
, you can submit the request first toPOST /signatures/prepare
(leaving these fields empty).
This will then return you a gas estimate + the next nonce.
Types of transaction
Vechain Transaction
{
walletId!: string,
submit!: boolean,
type!: VECHAIN_TRANSACTION,
blockRef?: string,
chainTag?: string,
expiration?: number,
gas?: number,
gasPriceCoef?: number,
nonce?: string,
clauses!: [{
to!: string,
amount?: number,
data?: string
}]
}
Bitcoin Transaction
{
walletId!: string,
submit!: boolean,
type!: BITCOIN_TRANSACTION,
to!: string,
value?: number,
feePerByte?: number
}
Litecoin Transaction
{
walletId!: string,
submit!: boolean,
type!: LITECOIN_TRANSACTION,
to!: string,
value?: number,
feePerKiloByte?: number
}
AEternity Transaction
{
walletId!: string,
submit!: boolean,
type!: AETERNITY_TRANSACTION,
to!: string,
value?: number,
data?: string,
nonce?: number,
fee?: number,
ttl?: number
}
Neo native Transaction
{
walletId!: string,
submit!: boolean,
type!: NEO_NATIVE_TRANSACTION,
to!: string,
value?: number
}
Neo gas Transaction
{
walletId!: string,
submit!: boolean,
type!: NEO_GAS_TRANSACTION,
to!: string,
value?: number
}
Hedera Transaction
{
walletId!: string,
submit!: boolean,
type!: HEDERA_TRANSACTION,
data?: string
}
Response Body:
{
type!: 'TRANSACTION_SIGNATURE',
signedTransaction!: string
}
Updated 7 months ago