Page: request emission
v.1 by Sergey Chernov
2018-11-27 18:11
2018-11-27 18:11
Asset emission
Providing user has the right to emit assets, client software must prepare emission request contract, like this:
ec = Contract.create @private_key
ec.definition[:name] = Emission::CONTRACT_NAME
ec.definition[:currency] = 'test_CHF'
ec.definition[:amount] = "100"
ec.seal()
ec.check().should be_truthy
res = json_post 'create', with_trace: true,contract_base64: ec.packed.to_base64
In other words, contract must:
- be issued with a single issuer key that is already registered
- has
definition.data.name == 'assets_emission_request'
- has
currency
set to a valid test currency,test_CHF
ortest_OIL
(api list is under way) - has amount set to a positive decimal string
then seal and check it and send transaction pack encoded in base64 to the
Request emission
POST /api/emissions
with parameters:
contract_base64
- the packed base64-encoded contract as described above.
The successcful result will contain emission record
:
{
"emission": {
"id": 38,
"state": "unconfirmed",
"confirm_mode": "sms",
"created_at": "2018-11-27T16:56:14Z",
"history": [
]
},
"status": "OK"
}
Here, unconfirmed
state means that the operation should be confirmed, and
confirmation mode is set to SMS only.
Note that the system may reject requests from users without confirmed mobile phone number.
Confirm emission
Using the id
obtained in the previous step:
POST /api/emissions/<id>/confirm
with the only parameter
sms_code
containing the code received from the SMS.
Use 1101 while testing, then the code you'll receive.
Check state
GET /api/emission/<id>
Will return emission record, as explained above.
Emission states, that client should react to:
state | meaning |
---|---|
unconfirmed | confirm with sms code or other method as prescribed in emission record |
confirmed | poll every 30s (testing) |
rejected | termination. did not pass control |
approved | continue polling, system will generate the coint contract soon |
success | termination, the record will contain contract_base64 structure with the emitted coin |