Sending Main Tokens

How to Send Main Tokens from the Console

You can send main tokens from the Luniverse Console.
For details, please refer to the link below:
토큰 전송
Luniverse

Sending Main Tokens through API

You can sen main tokens via API, not using the console.

Whitelist Registration

Delegation Contract. To pay the fee, you must be registered on the whitelist, and only the registered EOA can send tokens. Therefore, if EOA is not registered on the whitelist, it must be registered through the whitelist registration API.
The EOA includes the DEOA. The only difference is to sign whether via the API or directly in the signing process.

Running Whitelist Registration API

curl -X POST 'https://api.luniverse.io/mx/v2.0/delegation-contract/whitelist' \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"mainEnvironmentId": "<YOUR_MAIN_ENVIRONMENT_ID>",
"mainTokenSymbol": "<YOUR_MAIN_TOKEN_SYMBOL>",
"address": "<YOUR_EOA_ADDRESS>"
}'
  • You can find the “mainEnvironmentId” in the chain detail page URL of the console.
mainEnvironmentId
  • You need an authentication token to make API calls. To issue authentication tokens for API calls, see below. We will skip explaining about issuing authentication tokens in the following API explanation.

View Nonce

When you view rawTx, nonce is not included. You need to view the nonce of a particular address to include it in rawTx.

Running Nonce Viewing API

curl -X GET 'https://api.luniverse.io/mx/v2.0/wallets/{address}/nonce' \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'Content-Type: application/json' \

View rawTx

View Raw Transaction.

Running rawTx Viewing API

curl -X GET 'https://api.luniverse.io/mx/v2.0/token/main-tokens/{symbol}/transfer/raw-tx' \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"mainEnvironmentId": "<YOUR_MAIN_ENVIRONMENT_ID>",
"fromAddress": "<FROM_ADDRESS>",
"toAddress": "<TO_ADDRESS>",
"amount": "<AMOUNT>"
}'

Adding Nonce

Add nonce viewed on rawTx as a response from rawTx. ("nonce": "0x0" of the example below)
"rawTx":
{
"from": "0xa477c5efd0db9076aada98fda41ac017d3702dc1",
"data": "0xa9059cbb000000000000000000000000fb2b14428b7c36cf6c1142d79a9cef8daac925d60000000000000000000000000000000000000000000000000de0b6b3a764000011110000111195c498f246be383cb420141a23d1b6a66d5d44ba",
"gasLimit": "0x30d400",
"gasPrice": "0x15a7b2979400",
"chainId": 256,
"to": "0x6dacff06788e36f02de8fac798a52d99b11c78c6",
"nonce": "0x0"
}

Sign Raw Tx

1. Sign when DEOA

In the case of DEOA, you can create a signed tx via Remote sign API. Deliver nonce-added rawTx.
curl -X POST 'https://api.luniverse.io/mx/v2.0/wallets/{address}/sign' \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"rawTx": "<RAW_TX>"
}'

2. Sign when EOA

In the case of EOA, you can directly sign. There is no limit on signing Raw Tx, and we recommend using ethereumjs-tx in Javascript/Node.js enviornment.
const EthereumTx = require('ethereumjs-tx');
const privateKey = Buffer.from('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex');
// const apiResponse = {
// "result": true,
// "data": {
// "from": "0x6f183183a0701df756b1579ee7341759375cd57d",
// "rawTx": {
// "from": "0x6f183183a0701df756b1579ee7341759375cd57f",
// "to": "0x8a77685767f58cf6912bc5978213fd1d1de76864",
// "data": "0xa9059cbb00000000000000000000000062c1e49382823d33272cb161a625658d3adc07b70000000000000000000000000000000000000000000000000000000000000064",
// "chainId": 533162,
// "gasLimit": "0x30d400",
// "gasPrice": "0x1388"
// "nonce": "0x1",
// }
// }
// }
const tx = new EthereumTx(apiResponse.data.rawTx);
tx.sign(privateKey);
const signedTx = tx.serialize().toString('hex');

Running the Signed Transaction

Running Transaction-Sending API

curl -X POST 'https://api.luniverse.io/mx/v2.0/transaction/send/signed-tx' \
--header 'Authorization: Bearer <YOUR_API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"signedTx": "<SIGNED_TX>"
}'