-
Notifications
You must be signed in to change notification settings - Fork 0
/
createasset.py
38 lines (31 loc) · 1.33 KB
/
createasset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import os
import requests
import base64
client_id = os.environ.get('CLIENT_ID')# insert Moneybutton client id by export CLIENT_ID local file
client_secret = os.environ.get('CLIENT_SECRET')# insert MB client secret by using export CLIENT_SECRET local file
#Getting access token
cred64 = base64.b64encode(client_id.encode() + b":" + client_secret.encode())
response = requests.post(
'https://www.moneybutton.com/oauth/v1/token',
headers={'content-type': 'application/x-www-form-urlencoded',
'Authorization': b'Basic ' + cred64},
data={'grant_type' : 'client_credentials',
'scope' : 'application_access:write'}
)
resp_json = response.json()
access_token = resp_json["access_token"]
print(access_token)
#Creating asset
response = requests.post(
'https://www.moneybutton.com/api/v2/me/assets',
headers={'Authorization': 'Bearer ' + access_token},
data={
"protocol": "SFP",
"name": "Molly Match Token",
"initialSupply": 1000000,
"description": "This is for the GitHub repository on asset creation using Python.",
"avatar": "https://github.com/rachyrachyrach/moneybutton_asset_creation/blob/master/docs/images/mollymatch_paw.png",
"url": "https://github.com/rachyrachyrach/moneybutton_asset_creation"})
resp_json = response.json()
print(resp_json)