🟢Try it out

Learn how to try out the Wallet-API

Prerequisites

  1. You need a Venly business account, if you don't have one, click here to register, or view the Getting Started page.

  2. You need an active trial or paid subscription of the Wallet-API. You can start a trial for the Wallet-API as shown below.

  1. You need your Client ID and Client Secret which can be obtained from the Portal as shown below.

All the API calls for this guide run on a sandbox environment. You can test and experiment with API calls without causing any harm to the actual blockchain or data.

What we cover in this guide

This guide will walk you through several endpoints to help you get started with the Wallet-API. We will cover the following topics:

1. Authenticating

In order to obtain a bearer token and authorize all API calls, you will need your Client ID and Client Secret. These credentials are necessary for authentication purposes.

  1. Click here to open Swagger Wallet-API

  2. Click on the Authorize button

  3. Enter your Client ID and Client Secret

  4. Click the Authorize button on the bottom

You have authenticated successfully, and now you can run API calls.

All the endpoints will use base path:

https://api-wallet-sandbox.venly.io

2. Creating a Wallet

Let's begin by creating a wallet. Since you are currently using the API calls in a sandbox environment, the wallets will be created on a testnet chain.

In this example, we will create our first wallet on the MATIC Blockchain.

Learn more about testnet chains by clicking here.

Use the following endpoint to create your first wallet:

Request Body Parameters:

{
  "pincode": "123456", 
  "description": "Sample descriptive text", 
  "secretType": "MATIC"
}
ParameterTypeRequiredDescription

pincode

string

The PIN code serves as the password to access your wallet. Please remember it and keep it secure to ensure the protection of your wallet and its contents.

description

string

The description text for your wallet provides a brief summary. It can be used to describe the purpose or nature of the wallet in a concise manner.

secretType

string

This refers to the specific blockchain network on which you wish to create your wallet.

Response Body:

Save the following parameters from the response body. They will be used later in the guide.

  • id: This id is utilized to uniquely identify your wallet.

  • address: This is your public wallet address. You can provide this address to others to receive payments or initiate transfers to your wallet.

  • secretType: This is the blockchain name on which your wallet is created.

{
  "success": true,
  "result": {
    "id": "f4bbe06f-012a-4ae3-97bf-fbdee97fe1c4",
    "address": "0xfd551037D6eF400B8F01Dffc9858D5dD98899D86",
    "walletType": "API_WALLET",
    "secretType": "MATIC",
    "createdAt": "2023-07-19T09:06:13.714838114",
    "archived": false,
    "description": "Sample descriptive text",
    "primary": false,
    "hasCustomPin": true,
    "balance": {
      "available": true,
      "secretType": "MATIC",
      "balance": 0,
      "gasBalance": 0,
      "symbol": "MATIC",
      "gasSymbol": "MATIC",
      "rawBalance": "0",
      "rawGasBalance": "0",
      "decimals": 18
    }
  }
}

You have successfully created your first wallet.

3. Create second wallet

Next, let's move forward by creating a second wallet on the same blockchain (MATIC), but this time with a different PIN Code. To do so, use the following endpoint and replicate the previous steps.

After creating your second wallet, save the id and address somewhere. (It will be used later in the guide)

You now have two wallets on the MATIC testnet blockchain. Let's explore how you can add testnet coins to your wallet using a Faucet.

Learn more about testnet coins and Faucets by clicking here.

4. Topping up Wallet

Now we will add testnet coins to your first wallet. Testnet coins are necessary for conducting experiments, testing applications, and simulating transactions on a blockchain network without using real or valuable cryptocurrencies.

  1. Copy the address of your first wallet.

  2. Go to the MATIC Faucet by clicking here.

  3. Paste the address of your first wallet

  4. Click Submit

  5. Testnet coins will be sent to your wallet

5. Check Wallet Balance

Now let's check the balance of your first wallet.

To check the balance of your first wallet, use the following endpoint. Enter the id (walletId) of your first wallet and and execute the request. This will provide you with the current balance information.

Response Body

In the response body, locate the parameter called balance. For this example, the value of balance is 0.2. This indicates the amount of MATIC coins currently held in your wallet.

{
  "success": true,
  "result": {
    "available": true,
    "secretType": "MATIC",
    "balance": 0.2,
    "gasBalance": 0.2,
    "symbol": "MATIC",
    "gasSymbol": "MATIC",
    "rawBalance": "200000000000000000",
    "rawGasBalance": "200000000000000000",
    "decimals": 18
  }
}

6. Transferring Funds

At this point, you should have the first wallet containing some funds, while the second wallet remains empty.

We will run another endpoint where we will transfer some funds from the first wallet to the second wallet.

Use the following endpoint to initiate a transfer:

Request Body:

Description of parameters:

ParameterTypeRequiredDescription

pincode

string

The PIN code serves as the password to access your wallet. Please remember it and keep it secure to ensure the protection of your wallet and its contents.

transactionRequest

object

The description text for your wallet provides a brief summary. It can be used to describe the purpose or nature of the wallet in a concise manner.

type

string

This indicates type of transfer.

secretType

string

The blockchain of your wallet refers to the specific blockchain network from which you are transferring funds.

walletId

string

This is the id of the wallet from which the funds will be transferred. In this case, it refers to the first wallet.

to

string

This is the address of the destination wallet where the funds will be transferred to. In this case, it refers to the second wallet.

value

integer

The amount mentioned here refers to the quantity of coins that you intend to transfer.

{
  "pincode" : "123456",
  "transactionRequest": {
    "type" : "TRANSFER",
    "secretType" : "MATIC",
    "walletId" : "f4bbe06f-012a-4ae3-97bf-fbdee97fe1c4",
    "to" : "0xa1f04C769155195D83c7f16bC6B9540139C80b2A",
    "value": 0.1 
    }
  }

Response Body:

Save the transactionHashfor later use in this guide.

transactionHash: You can use this transaction hash to check the current status of this specific transaction.

{
  "success": true,
  "result": {
    "id": "9714aa64-4663-4b2f-abd5-3cdd7a347f93",
    "transactionHash": "0xc1c636ba63759ea3c8080fee0bfb8bd09ee6bb5464cad30dee1323605a758d7e"
  }
}

The "success": true in response body indicates that the transfer request was submitted successfully. It does not mean the fund transfer was completed.

Since this transfer call is being made on a sandbox environment and testnet blockchain, it's important to note that the funds may arrive instantly.

To verify whether a transfer has been successfully completed, it is necessary to check the transaction status. This status will provide information on whether the transfer was successful or if it encountered any issues resulting in a failure.

Mainnet Blockchain transactions are never immediate. They require time for processing, and the duration can vary depending on the specific blockchain network.

7. Check transaction status

To confirm whether a specific transaction was successful or not, you can check its status using the provided endpoint.

To obtain the status of the transaction, please provide the required information. Set the secretType as "MATIC" and enter the transactionHash that you had saved earlier.

Response Body:

From the response body, you can see that the status is "SUCCEEDED." This indicates that the transaction was successfully executed and completed.

Funds have been sent from the first wallet to the second.

{
  "success": true,
  "result": {
    "hash": "0xc1c636ba63759ea3c8080fee0bfb8bd09ee6bb5464cad30dee1323605a758d7e",
    "status": "SUCCEEDED",
    "confirmations": 15,
    "blockHash": "0x3c9a23764f52e8bff64a3435249fa0c22fd0090bb5838e20a2aebfa025377496",
    "blockNumber": 38105564,
    "hasReachedFinality": false,
    "chain": "MATIC",
    "nonce": 2,
    "gas": 21000,
    "gasUsed": 21000,
    "gasPrice": 100000000000,
    "from": "0xfd551037d6ef400b8f01dffc9858d5dd98899d86",
    "to": "0xa1f04c769155195d83c7f16bc6b9540139c80b2a",
    "rawValue": 100000000000000000,
    "value": 0.1,
    "timestamp": "2023-07-19T09:37:09"
  }
}

8. Check balance after transfer

Let's use the same endpoint once again to check the balance of your second wallet. Please provide the id (walletId) of your second wallet to retrieve the updated balance information.

Last updated