GetSmartContractCode
Returns the Scilla code associated with a smart contract address. This is represented as a String
.
Example Request
- cURL
- node.js
- java
- python
- go
curl -d '{
"id": "1",
"jsonrpc": "2.0",
"method": "GetSmartContractCode",
"params": ["fe001824823b12b58708bf24edd94d8b5e1cfcf7"]
}' -H "Content-Type: application/json" -X POST "https://api.zilliqa.com/"
Example Response
{
"id": "1",
"jsonrpc": "2.0",
"result": {
"code": "scilla_version 0\n\n (* HelloWorld contract *)\n \n import ListUtils\n \n (***************************************************)\n (* Associated library *)\n (***************************************************)\n library HelloWorld\n \n let one_msg = \n fun (msg : Message) => \n let nil_msg = Nil {Message} in\n Cons {Message} msg nil_msg\n \n let not_owner_code = Int32 1\n let set_hello_code = Int32 2\n \n (***************************************************)\n (* The contract definition *)\n (***************************************************)\n \n contract HelloWorld\n (owner: ByStr20)\n \n field welcome_msg : `String` = \"\"\n \n transition setHello (msg : `String`)\n is_owner = builtin eq owner _sender;\n match is_owner with\n | False =>\n msg = {_tag : \"Main\"; _recipient : _sender; _amount : Uint128 0; code : not_owner_code};\n msgs = one_msg msg;\n send msgs\n | True =>\n welcome_msg := msg;\n msg = {_tag : \"Main\"; _recipient : _sender; _amount : Uint128 0; code : set_hello_code};\n msgs = one_msg msg;\n send msgs\n end\n end\n \n \n transition getHello ()\n r <- welcome_msg;\n e = {_eventname: \"getHello()\"; msg: r};\n event e\n end"
}
}
HTTP Request
Chain(s) | URL(s) |
---|---|
Zilliqa mainnet | https://api.zilliqa.com/ |
Developer testnet | https://dev-api.zilliqa.com/ |
Local testnet | http://localhost:4201/ |
Isolated server | https://zilliqa-isolated-server.zilliqa.com/ |
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
id | string | Required | "1" |
jsonrpc | string | Required | "2.0" |
method | string | Required | "GetSmartContractCode" |
params | string | Required | A smart contract address of 20 bytes. Example: "fe001824823b12b58708bf24edd94d8b5e1cfcf7" |