You can get this information from your wallet. If you use the desktop wallet you can go to tools backup and it will produce a backup json that has this information. If you created your wallet using the cli tool axe then it produces the same json as the desktop wallet.
You can see the address and public_key needed for the POST request mentioned above.
It is recommened to use FAST for the kind - this is the transaction kind and fast transactions are instant
the fee for sending a transaction is 0.0001 - The API has an endpoint that lists the fees
So now you can make a POST request to the endpoint https://mainnet.axentro.io/api/v1/transaction/send_token/unsigned with the json mentioned above as the payload.
The request will return a response with a transaction json that you can sign and POST to make the actual transaction.
Signing the generated transaction json
The json returned from the api/v1/transaction/send_token/unsigned endpoint should look similar to this:
Remove the surounding json for status and result and just take the payload in the result so you have just the payload of the json with all spaces and new lines removed. If you get this wrong the hash will not match and the transaction will be rejected with invalid signing.
Next you need turn the json above into a SHA256 hash and then sign it with your private key that you must convert from your WIF from your wallet json.
Getting a SHA256
var SHA256 = require("crypto-js/sha256");
var transaction_hash = SHA256('compact_json_string_with_no_spaces_or_new_lines')
Getting your private key from the WIF
In your wallet json next to the public key and address there is a wif. This is a wallet information format key that has the private key inside that is needed for signing.
var getPrivateKeyAndNetworkFromWif = function(wif) {
var decodedWif = all_crypto.base64.Base64.decode(wif);
var networkPrefix = decodedWif.substring(0, 1);
var network = networkPrefix === "M0" ? mainnet : testnet;
var privateKeyHex = decodedWif.substring(2, decodedWif.length - 6);
return {
privateKey: privateKeyHex,
network: network
};
};
Signing the transaction hash
var sign = function(privateKey, message) {
var ec = new all_crypto.elliptic.eddsa('ed25519');
var key = ec.keyFromSecret(privateKey);
var signature = key.sign(all_crypto.buffer.Buffer.from(message, 'utf8')).toHex().toLowerCase();
return signature;
};
The private key is the one you got from the WIF and the message is the transaction_hash you made earlier. This funciton produces a signature which you then paste into the signature field of the sender in the compact json and post to the transaction endpoint http://mainnet.axentro.io/api/v1/transaction with the payload wrapped in a transaction elements as follows: