Creating an API for working with the blockchain
Hello world! There is an interesting task - the creation of an API for working with the blockchain of two cryptocurrencies (perhaps the list will be replenished):
Algorand - https://www.algorand.com
Terra - https://www.terra.money
You must implement apis to work with the method, which are described below.
If you use PHP, then the minimum version of PHP is 8.1, for implementation on PHP API you can not implement, there are enough scripts.
Preferences for languages: php, js
At the entrance you accept:
currency — currency (for example, TRX)
token – (e.g. trc20)
contract_address - Contract Addresses
Depending on whether you have transferred a token or a coin, as a result, you work with either a contract or "without it" accordingly.
If the work with the token - currency is not transferred.
Note:
Responses in json. Return a successful result to result if an error occurred during execution - http code=500, in error - the error itself.
Create an address No incoming data, the address is not created on the node, but offline.
You must return:
address — wallet address
password — private key
Wallet Balance Request:
address - wallet addresses
Answer:
balance — wallet balance in currency (string)
Wallet ValidationRequest:
address - wallet addresses
Answer:
is_valid — true|false
Withdrawal Request Request
from_address - wallet addresses
from_password is the private key of the wallet
amount - amount
address — address where to withdraw
Answer:
txid — txid transactions
Transaction Information Request:
txid — txid transactions
Answer:
status -
paid — successful
wait - Not Confirmed
fail - transaction errors
fee – network commission, array
amount - amount
currency - currency paid — successful, wait — not confirmed, fail — transaction errors
Notification of a new transaction, block You need to receive new blocks and parse them, pull out transactions and information about them. All parsed transactions must be sent via http. Save the last split block and start with it when you fall.
Query:
transactions - Transaction Array
Transaction structure:
block_number is the block number
from_address - from whom the transaction to_address came - to which address
amount — amount
txid - hash
c ontract_address - the address of the counterpart (may not be)
If there are any questions - I will be happy to answer them!
28.04.2022 12:38