Issuing custom Assets
To issue a new type of asset, all you need to do is choose a code. It can be any combination of up to 12 letters or numbers, but you should use the appropriate ISO 4217 code (e.g. USD for US dollars) or ISIN for national currencies or securities. Once you’ve chosen a code, you can list your asset in the platform and begin paying people using that asset code.
// List your asset in the platform
const asset = await bitcapital.assets().create({
name: 'My Awesome Personal Coin',
code: 'MAPC',
});
// Emit some MAPC tokens to a specific wallet
const transaction = await bitcapital.assets().emit({
code: 'MAPC',
amount: '10.00',
destination: 'eef00b8e-8e16-4421-9628-af25d908b69b'
});
curl --location --request POST 'https://instance-url.btcore.app/assets/MACP/emit' \
--header 'Authorization: Bearer 0000000000000000000000000000000000000000'\
--header 'Content-Type: application/json' \
--header 'X-Request-Signature: 140cf3238103cb985a3438fa3080401f9eb72523172f1a9725482c74a003d4993b' \
--header 'X-Request-Timestamp: 1578678110828' \
--data-raw '{
"amount": "10.00",
"destination": "eef00b8e-8e16-4421-9628-af25d908b69b"
}'
P2P With Custom Assets
After a successful asset emission, you can use it in P2P Payments payments as any other asset:
// P2P payment in MAPC tokens between two consumers
const transaction = await bitcapital.payments.pay({
source: 'eef00b8e-8e16-4421-9628-af25d908b69b',
recipients: [{
asset: 'MAPC',
amount: '1.50',
destination: '89fea8d4-fe87-4863-8dc8-f4bd6e4399e7'
}]
curl --location --request POST 'https://instance-url.btcore.app/payments' \
--header 'Authorization: Bearer 0000000000000000000000000000000000000000'\
--header 'Content-Type: application/json' \
--header 'X-Request-Signature: 140cf378103cb985a938fa3080401f9eb72524172f1a9725482c74a003d4993b' \
--header 'X-Request-Timestamp: 1578678110828' \
--data-raw '{
"source": "eef00b8e-8e16-4421-9628-af25d908b69b",
"recipients": [{
"asset": "MACP",
"amount": "1.50",
"destination": "89fea8d4-fe87-4863-8dc8-f4bd6e4399e7"
}]
}'
Updated over 4 years ago