All requests are sent by POST method to the following URL: https://faucet.cryptonex.org/api/jsonrpc
curl -i -X POST -H "Content-Type: application/json; indent=4" -d '{ "jsonrpc": "2.0", "method": "coin.get", "params": { "address": "mnCxoseek8b93wGzztF4RM97vU3XqAfQ4u", "coins": "10" }, "id": "1" }' https://faucet.cryptonex.org/api/jsonrpc
Method name | coin.get |
---|---|
Params |
address – your cryptoaddress; coins – the number of coins, optional parameter, takes values from 1 to 10 inclusively; if there is no value or a value is specified out of the range, it automatically becomes 10 |
Example |
|
Response success |
|
Response error |
// When the last transaction has not passed within 24 hours
// When the method does not exist
|
import requests
import json
import sys
def coin_get(address, coins=10):
url = "https://faucet.cryptonex.org/api/jsonrpc"
headers = {'content-type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "coin.get",
"params": {
"address": address,
"coins": str(coins)
}
}
response = None
try:
response = requests.post(url, data=json.dumps(
payload), headers=headers)
except Exception:
print('Error connection')
return False
if response.status_code == requests.codes.ok:
response =response.json()
if "error" in response.keys():
print(response["error"]["message"])
return False
else:
print(response["result"]["message"])
print('txid:', response["result"]["txid"])
return response["result"]["txid"]
else:
print('Error code:', response.status_code)
return False
if __name__ == '__main__':
if len(sys.argv) <= 1 or len(sys.argv) > 3:
print('Usage: cnxtest.py <CNX testnet address> [amount]')
exit(0)
amount = 10
if len(sys.argv) == 3:
amount = int(sys.argv[2])
if amount <= 0:
print('Wrong amount')
coin_get(sys.argv[1], amount)