ERC20 Token Api

REST API developed using Node.js/Typescript microservice which can interact with Ethereum blockchain and Matic network.

All requests should include Bearer token.

Inside API stored Ethereum wallet (public/private) keys, which is responsobile for transaction signing and sending. Currently platform use Ropsten and Testnetv3 networks.

Ethereum network methods

Methods for interact with Ethereum network (Ropsten). Port 3000.

GET

Server address details

http://bcs.oropocket.com:3000/api/rootAddressBalances

This method returns a balance of server based wallet. Its allow to control the state before sending funds to another address. The number of digits to appear after the decimal point is 6.

Returns:

  • address: ETH address of server based wallet (string)
  • gold: GOLD token balance of wallet (string)
  • silver: SILVER token balance of wallet (string)
  • eth: ETH balance of wallet (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>


Example Request
Server address details
curl --location --request GET 'http://bcs.oropocket.com:3000/api/rootAddressBalances'
GET

Any address details

http://bcs.oropocket.com:3000/api/addressBalances

This method returns a balance of certain ETH wallet. ETH wallet should be included on body or request. The number of digits to appear after the decimal point is 6.

Params:

  • address: ETH address of certain user (string)

Returns:

  • address: ETH address of server based wallet (string)
  • gold: GOLD token balance of wallet (string)
  • silver: SILVER token balance of wallet (string)
  • eth: ETH balance of wallet (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "address":"0xe910EE7caC44c890d89B220B182f46b4123f091A"
                                                            }


Example Request
Any address details
curl --location --request GET 'http://bcs.oropocket.com:3000/api/addressBalances' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "address":"0xe910EE7caC44c890d89B220B182f46b4123f091A"
                                                            }'
GET

Get all wallets

http://bcs.oropocket.com:3000/api/getAllAccounts

This method returns array of wallets of all registered users on db. Each item includes information about that account.

Returns:

  • id: Numerical id of wallet in DB (number)
  • publicKey: ETH address of user wallet (string)
  • created: Wallet creation timestamp (string)

AUTHORIZATION

Bearer Token


token
<token>


Example Request
Get all wallets
curl --location --request GET 'http://bcs.oropocket.com:3000/api/getAllAccounts'
POST

Transfer tokens

http://bcs.oropocket.com:3000/api/transfer

Transfer certain amount of tokens from sender wallet to receiver wallet. The sender wallet should be stored on API database (check Get all wallets method), otherwise transaction will be failed.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • sender: ETH address of account who send tokens (string)
  • receiver: ETH address of account who should receive tokens (string)
  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • fee: fee of transaction in ETH, float number (string)
  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "sender":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }


Example Request
Transfer tokens
curl --location --request POST 'http://bcs.oropocket.com:3000/api/transfer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "sender":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }'
POST

Transfer server tokens

http://bcs.oropocket.com:3000/api/transferFromServer

Transfer certain amount of tokens from server based wallet to receiver wallet. The method works the same way as Transfer tokens method, but in this case sender parameter is not needed.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • receiver: ETH address of account who should receive tokens (string)
  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • fee: fee of transaction in ETH, float number (string)
  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "receiver":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }


Example Request
Transfer server tokens
curl --location --request POST 'http://bcs.oropocket.com:3000/api/transferFromServer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "receiver":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }'
POST

Create ETH wallet

http://bcs.oropocket.com:3000/api/createAccount

Method creates new eth wallet (public\private keys), and save it on DB. Only public key can be reachable for requests, private key is hidden from external requests. The cethod can be used during new user registration.

Returns:

  • id: numerical id of new created wallet (number)
  • address: the address of new wallet (public key) (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json


Example Request
Create ETH wallet
curl --location --request POST 'http://bcs.oropocket.com:3000/api/createAccount' \
                                                            --header 'Content-Type: application/json'
POST

Mint new tokens

http://bcs.oropocket.com:3000/api/mint

Mint certain amount of new tokens to certain ETH address.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • receiver: ETH address who should receive minted tokens (string)
  • amount: amount of tokens (in ETH format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                            "receiver":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                            "amount": "10",
                                                            "tokenId": "0"
                                                        }


Example Request
Mint new tokens
curl --location --request POST 'http://bcs.oropocket.com:3000/api/mint' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "receiver":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }'
POST

Mint tokens to server wallet

http://bcs.oropocket.com:3000/api/mintToServer

Mint certain amount of new tokens to server based wallet. This method should be used after burning tokens on Matic network.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • amount: amount of tokens (in ETH format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                            "amount": "0.1",
                                                            "tokenId": "0"
                                                        }


Example Request
Mint tokens to server wallet
curl --location --request POST 'http://bcs.oropocket.com:3000/api/mintToServer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "amount": "0.1",
                                                                "tokenId": "0"
                                                            }'
POST

Burn tokens

http://bcs.oropocket.com:3000/api/burn

Burn certain amount tokens from server based ETH address balance. Should be used after deposit tokens on Matic network.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "amount": "2.563477",
                                                                "tokenId": "0"
                                                            }


Example Request
Burn tokens
curl --location --request POST 'http://bcs.oropocket.com:3000/api/burn' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "amount": "2.563477",
                                                                "tokenId": "0"
                                                            }'

Matic network methods

Methods for interact with Matic network (Testnetv3). Port 4000.

POST

Transfer tokens

http://bcs.oropocket.com:4000/api/transfer

Transfer certain amount tokens to certain ETH address inside Matic network. Request includes 2 micro-transactions:

  1. Sending ETH from Server wallet -> Sender wallet for covering token transfer fee
  2. Transfer tokens from Sender wallet -> Receiver wallet

All params should be included on body or request.

Params:

  • sender: ETH address of account who should receive tokens (string)
  • receiver: ETH address of account who should receive tokens (string)
  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • feeTransferTx: hash of generated tx of fee transfer (Admin -> Sender) (string)
  • tokenTransferTx: hash of generated tx of tokens transfer (Sender -> Receiver) (number)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "sender":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "1",
                                                                "tokenId": "0"
                                                            }


Example Request
Transfer tokens
curl --location --request POST 'http://bcs.oropocket.com:4000/api/transfer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "sender":"0xe910EE7caC44c890d89B220B182f46b4123f091A",
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "1",
                                                                "tokenId": "0"
                                                            }'
POST

Mint tokens to server wallet

http://bcs.oropocket.com:4000/api/mintToServer

Mint certain amount of new tokens to server based wallet. This method should be used after burning tokens on Ethereum network.

All params should be included on body or request. API wait for 1 confirmation from blockchain and then response to request.

Params:

  • amount: amount of tokens (in ETH format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated tx (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }


Example Request
Mint tokens to server wallet
curl --location --request POST 'http://bcs.oropocket.com:4000/api/mintToServer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "amount": "10",
                                                                "tokenId": "0"
                                                            }'
POST

Transfer server tokens

http://bcs.oropocket.com:4000/api/transferFromServer

Transfer certain amount of tokens from server based wallet to receiver wallet. The method works the same way as Transfer tokens method, but in this case sender parameter is not needed.

All params should be included on body or request.

Params:

  • receiver: ETH address of certain user (string)
  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated transaction (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "5",
                                                                "tokenId": "0"
                                                            }


Example Request
Transfer server tokens
curl --location --request POST 'http://bcs.oropocket.com:4000/api/transferFromServer' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "receiver":"0x84B81d05958Fe7AFcc20fB7d2374fd0a9A503e71",
                                                                "amount": "5",
                                                                "tokenId": "0"
                                                            }'
POST

Burn tokens

http://bcs.oropocket.com:4000/api/burn

Burn certain amount tokens from server based ETH address balance. Should be used after withdraw tokens on Ethereum network.

All params should be included on body or request.

Params:

  • amount: amount of tokens (in Eth format, with max 6 numbers after decimal point) (string)
  • tokenId: '0' for GOLD, '1' for SILVER

Returns:

  • transaction: hash of generated tx (string)
  • blockNumber: block number where tx included (number)
  • timestamp: current unix timestamp, it can be used as a startpoint for calculate delay until withdraw confirmation (number)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "amount": "0.1",
                                                                "tokenId": "0"
                                                            }


Example Request
Burn tokens
curl --location --request POST 'http://bcs.oropocket.com:4000/api/burn' \
                                                                --header 'Content-Type: application/json' \
                                                                --data-raw '{
                                                                    "amount": "0.1",
                                                                    "tokenId": "0"
                                                                }'
GET

Server address details

http://bcs.oropocket.com:4000/api/rootAddressBalances

This method returns a balance of server based wallet. Its allow to control the state before sending funds to another address. The number of digits to appear after the decimal point is 6.

Returns:

  • address: ETH address of server based wallet (string)
  • gold: Matic GOLD token balance of wallet (string)
  • silver: Matic SILVER token balance of wallet (string)
  • eth: Matic ETH balance of wallet (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>


Example Request
Server address details
curl --location --request GET 'http://bcs.oropocket.com:4000/api/rootAddressBalances'
GET

Any address details

http://bcs.oropocket.com:4000/api/addressBalances

This method returns a balances of certain ETH wallet inside Matic network. After deposit tokens to the Matic method indexing will take some period, so tokens will not be visible immediately after deposit. ETH wallet should be included on body or request. The number of digits to appear after the decimal point is 6.

Params:

  • address: ETH address of certain user (string)

Returns:

  • address: ETH address of server based wallet (string)
  • gold: Matic GOLD token balance of wallet (string)
  • silver: Matic SILVER token balance of wallet (string)
  • eth: Matic ETH balance of wallet (string)
  • success: the result of request (boolean)

AUTHORIZATION

Bearer Token


token
<token>
HEADERS

Content-Type
application/json
BODY raw


{
                                                                "address":"0xe910EE7caC44c890d89B220B182f46b4123f091A"
                                                            }


Example Request
Any address details
curl --location --request GET 'http://bcs.oropocket.com:4000/api/addressBalances' \
                                                            --header 'Content-Type: application/json' \
                                                            --data-raw '{
                                                                "address":"0xe910EE7caC44c890d89B220B182f46b4123f091A"
                                                            }'