GetContractFromTransaction()
Summary
Route | Type | Example |
---|---|---|
/contract/getfromtransaction | POST | http://apinode.credits.com/api/contract/getfromtransaction |
Description
Get smart contract source code from a transaction.
Request
Request Structure
x
// Parameters common for all requests
"transactionId": "Decimal_String", // Smart contract address in Base58
“compressed”: boolean value // Indicator of data compression true or false
}
Request Parameters
transactionId: transactionId- transaction identifier in the form block_number.transaction_number
bool: Compressed - Request compressed data True or False
Response
JSON output depends on the request type and its success.
If there’s an error, request returns to the node basic Result:
- Success: False
- Message:
If successful, requested information is returned.
Response Structure
{
"gZipped":Bytes, // Source code of smart contract Compressed
"sourceString":"String", // Source code of smart contract in String Value
"success":bool, // Shows if request was Succes or False Boolean Value
"message":"String" // Shows if a problem occurred with request in String Value
}
Example Code
import requests
import json
def Getcontractbytransaction():
url = 'http://apinode.credits.com/api/contract/getfromtransaction'
headers = {
'Content-type': 'application/json'
, 'Accept': 'application/json'
, 'Content-Encoding': 'utf-8'
}
data = {
"NetworkAlias":"Mainnet"
, "transactionId":"25920647.1"
, "compressed": False
}
answer = requests.post(url, data=json.dumps(data), headers=headers)
response = answer.json()
print(response)
Getcontractbytransaction()