Metacoin API
MetacoinMetaWallet Deeplink APIMetascanRedscan
Metacoin API
Metacoin API
  • Metacoin API
  • Quick Start
  • Reference
    • REST API Reference
      • Address
      • Block and transaction
      • Token
      • MRC400(NFT)
      • MRC402(NFT)
Powered by GitBook
On this page
Edit on GitHub
  1. Reference
  2. REST API Reference

Address

Metacoin Address and balance

PreviousREST API ReferenceNextBlock and transaction

Last updated 1 year ago

<?php
// Create New Address example code


// Create new key pair
$new_key_pair = openssl_pkey_new(array(
    "private_key_type" => OPENSSL_KEYTYPE_EC,
    'curve_name' => 'secp384r1',
));
openssl_pkey_export($new_key_pair, $private_key_pem);
$details = openssl_pkey_get_details($new_key_pair);
$public_key_pem = $details['key'];

$param = array(
	'publickey' => $public_key_pem,
	'addinfo' => 'new address'
);

// HTTP Request
$curl = curl_init();
$opt = curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://testnetrest.metacoin.network:20923/address',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_CONNECTTIMEOUT => 5,
	CURLOPT_TIMEOUT => 20,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_SSL_VERIFYHOST => false,
	CURLOPT_POST => false,
	CURLOPT_POSTFIELDS => http_build_query($param),
	CURLOPT_POST => true,
));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

$body = curl_exec($curl);
if(curl_errno($curl)){
	$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
	printf("API Error [%d] %s", $http_code, $body);
	exit;
}

printf("New Address : %s\n", $body);
printf("Private Key : %s\n", $private_key_pem);

Create new Adderess

post

Warning!!

  • An ECDSA private key that is paired with the ECDSA public key is used to authorize the transfer.
  • When you make your wallet, please keep the Private Key that is paired with the Public Key you sent in a safe place.
  • If you lose your private key, you can not claim your wallet.
  • ECDSA curve is prime256v1(secp256r1) or secp384r1 or secp521r1.
Query parameters
publickeystring · pem encodingRequired

ECDSA Public key for signing

addinfostring · max: 2048Optional
  • Address memo
  • Up to 2048 characters are stored, and characters after 2048 characters are not stored.
Responses
200
successful operation
*/*
Responsestring · Metacoin Address

new Metacoin address

405
Missing or invalid RSA key
text

Get address status

get
Path parameters
addressstring · Metacoin AddressRequired

Metacoin address

Responses
200
successful operation
*/*
404
Address not found
get
GET /address/{address} HTTP/1.1
Host: rest.metacoin.network:20923
Accept: */*
{
  "address": "text",
  "createdate": 1,
  "balance": [
    {
      "token": "text",
      "balance": "text",
      "unlockdate": 1
    }
  ]
}

Get address list by public key

post
Query parameters
publickeystringRequired
  • Metacoin address's public key
  • ignore carriage return, line feed, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"
Example: -----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBBp5oHHFaATF1UIephJYgtW+u2+aT\nhZLxNgn5JZhgFXzvTUHlThZxb61eTXMMjyU/IloNznwtzRWuPq1oMDOMq9oBbT/t\nE4lgyPF5/QtzuhaaYRpr/ahZ4JSLyHOegkopXeic3UFUmkpb4mXuSGgu5mChuuUC\nktjfluGNtvXHOWYtqTU=\n-----END PUBLIC KEY-----
Responses
200
successful operation
*/*
Responsestring · Metacoin Address[]Example: MTATLnT6SGKE8RU0CBPoDRfUXL5lr4SLece1a6ee
404
Address not found
[
  "MTATLnT6SGKE8RU0CBPoDRfUXL5lr4SLece1a6ee"
]

Get Temporary key(nonce) for ganerate transaction(ex Transfer, Dapp Create or Token Create)

get
  • By using the signature value recorded in the transaction, the key value is obtained to prevent duplicate calls by other users.
  • In the existing blockchain, the nonce value is a serial number that means the number of TX occurrences, but in Metacoin, it is a random key value.
  • This command replaces the existing "getkey" API.
Path parameters
addressstring · Metacoin addressRequired

Address to get nonce value

Responses
200
successful operation
*/*
Responsestring

Temporary key for transaction

400
address not exists
get
GET /nonce/{address} HTTP/1.1
Host: rest.metacoin.network:20923
Accept: */*
text

Get balance of address

get
Path parameters
addressstring · Metacoin addressRequired

Metacoin address

Responses
200
successful operation
*/*
404
Address not found
get
GET /balance/{address} HTTP/1.1
Host: rest.metacoin.network:20923
Accept: */*
{
  "token": "text",
  "balance": "text",
  "unlockdate": 1
}
  • POSTCreate new Adderess
  • GETGet address status
  • POSTGet address list by public key
  • GETGet Temporary key(nonce) for ganerate transaction(ex Transfer, Dapp Create or Token Create)
  • GETGet balance of address