How to sign RAW transactions?

This page describes how to sign raw transactions and submit them yourself to the blockchain.

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.

Endpoint

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

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: Type
}
FieldTypeMandatoryDescription

pincode

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

Custom Fields

EVM based chains

This applies to the following types ETHEREUM_TRANSACTION , BSC_TRANSACTION , AVAC_TRANSACTION , MATIC_TRANSACTION and GOCHAIN_TRANSACTION .

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: Type,
  
  to!: string,
  value?: number,
  data?: string,
  gas!: number,
  gasPrice!: number,
  nonce!: number
}

FieldTypeMandatory?Description

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

Vechain Transaction

{
  pincode!: string,
  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

 {
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: BITCOIN_TRANSACTION,
  
  to!: string,
  value?: number,
  feePerByte?: number
}

Litecoin Transaction

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: LITECOIN_TRANSACTION,
  
  to!: string,
  value?: number,
  feePerKiloByte?: number
}

AEternity Transaction

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: AETERNITY_TRANSACTION,
  
  to!: string,
  value?: number,
  data?: string,
  nonce?: number,
  fee?: number,
  ttl?: number
}

Neo native Transaction

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: NEO_NATIVE_TRANSACTION,
  
  to!: string,
  value?: number
}

Neo gas Transsaction

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: NEO_GAS_TRANSACTION,
  
  to!: string,
  value?: number
}

Hedera Transaction

{
  pincode!: string,
  walletId!: string,
  submit!: boolean,
  type!: HEDERA_TRANSACTION,
  
  data?: string
}

Response

{
  type!: 'TRANSACTION_SIGNATURE',
  signedTransaction!: string
}

Last updated