Address
Metacoin Address and balance
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
post
const crypto = require('crypto');
const axios = require('axios');
// testnet
var hostname = "https://testnetrest.metacoin.network:20923";
// mainnet
// hostname = "https://rest.metacoin.network:20923";
function create_address() {
return new Promise((resolve, reject) => {
crypto.generateKeyPair("ec", {
namedCurve: "secp384r1", // prime256v1, secp384r1, secp521r1
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem'
}
}, (err, public_key, private_key) => {
if (err != null) {
return reject(err.message);
}
axios.post(hostname + '/address', {
'publickey': public_key
})
.then(function (response) {
if (response.status != 200) {
return Promise.reject("MTC server response errror");
} else {
return Promise.resolve(response.data);
}
})
.then(function (mtc_address) {
return resolve({ "Address": mtc_address, "publicKey": public_key, "PrivateKey": private_key });
})
.catch(function (error) {
return reject(error);
});
});
});
}
create_address()
.then((v) => {
console.log('Metacoin Address', v.Address);
console.log('Public Key', v.publicKey);
console.log('Private Key', v.PrivateKey);
})
.catch((err) => {
console.log(err);
});
text
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
}
]
}
Query parameters
publickeystringRequiredExample:
- Metacoin address's public key
- ignore carriage return, line feed, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"
-----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
post
const crypto = require('crypto');
const axios = require('axios');
// testnet
var hostname = "https://testnetrest.metacoin.network:20923";
// mainnet
// hostname = "https://rest.metacoin.network:20923";
var public_key = "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBBp5oHHFaATF1UIephJYgtW+u2+aT\nhZLxNgn5JZhgFXzvTUHlThZxb61eTXMMjyU/IloNznwtzRWuPq1oMDOMq9oBbT/t\nE4lgyPF5/QtzuhaaYRpr/ahZ4JSLyHOegkopXeic3UFUmkpb4mXuSGgu5mChuuUC\nktjfluGNtvXHOWYtqTU=\n-----END PUBLIC KEY-----";
// public_key = "MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBBp5oHHFaATF1UIephJYgtW+u2+aThZLxNgn5JZhgFXzvTUHlThZxb61eTXMMjyU/IloNznwtzRWuPq1oMDOMq9oBbT/tE4lgyPF5/QtzuhaaYRpr/ahZ4JSLyHOegkopXeic3UFUmkpb4mXuSGgu5mChuuUCktjfluGNtvXHOWYtqTU=";
axios.post(hostname + '/address/bykey', {
'publickey': public_key
}, {
proxy: {
host: '127.0.0.1',
port: 8888
}
})
.then(function (response) {
if (response.status != 200) {
return Promise.reject("Metacoin server response error");
} else {
return Promise.resolve(response.data);
}
})
.then(function (mtc_address) {
// ["MT4FzIQCgRh0T1YD841OxjNd3dkfTJcEd41d17d3"]
console.log(mtc_address);
})
.catch(function (error) {
if (error.response.status == 404) {
console.log("Address not found");
} else {
console.log(error);
}
});
[
"MTATLnT6SGKE8RU0CBPoDRfUXL5lr4SLece1a6ee"
]
- 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
Last updated