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 know 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

ParameterParam TypeValueDescription
Signing-MethodHeaderid:valueid: This is the ID of the signing method
value: This is the value of the signing method
FieldTypeDescriptionMandatory
pincode (Deprecated)StringThe PIN code of the wallet that needs to sign for this request.โŒ
walletIdStringThe ID of the wallet you want to use to sign the transaction.โœ…
submitbooleanWhether or not you also immediately want to submit the transaction to the blockchain.โœ…
typeTypeThe 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
}
FieldTypeDescriptionMandatory?
toStringThe destination of the transaction.โœ…
valuenumberThe amount of native currency in wei (e.g. Ether, Matic, BNB) you want to include in the transaction.โŒ
dataStringThe data you want to include in the transaction (if any). Here you can for example add an encoded contract call (encodedFunction).โŒ
gasnumberThe max amount of gas (gas limit) this transaction is allowed to use.โœ…
gasPricenumberThe price in wei that you want to pay for one amount of gas.โœ…
noncenumberThe nonce (sequence) of the transaction.โœ…

๐Ÿ“˜

If you want a prediction of the gas/gasPrice and the next nonce, you can submit the request first to POST /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
}