Created
February 8, 2022 10:22
-
-
Save ilyar/8b1f848f2843ee4ff6cafb1086287abb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma ton-solidity >=0.40.0; | |
| pragma AbiHeader expire; | |
| pragma AbiHeader time; | |
| pragma AbiHeader pubkey; | |
| import "https://raw.githubusercontent.com/tonlabs/debots/main/Debot.sol"; | |
| import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Terminal/Terminal.sol"; | |
| import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Media/Media.sol"; | |
| import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Network/Network.sol"; | |
| contract Example is Debot { | |
| function start() public override { | |
| _start(); | |
| } | |
| function _start() private pure { | |
| Terminal.input(tvm.functionId(handlerText), "Enter name:", false); | |
| } | |
| function handlerText(string value) public { | |
| string[] headers; | |
| string url = "https://rest.nearapi.org/view"; | |
| headers.push("Content-Type: application/json"); | |
| string body = format('{ "contract": "alpha.neatar.testnet", "method": "avatar_of", "params": { "account_id": "{}"}}', value); | |
| Network.post(tvm.functionId(handlerResponse), url, headers, body); | |
| } | |
| function handlerResponse(int32 statusCode, string[] retHeaders, string content) public { | |
| Media.output(tvm.functionId(setResult), "", content); | |
| } | |
| function setResult(MediaStatus result) public pure { | |
| require(result == MediaStatus.Success); | |
| _start(); | |
| } | |
| function getRequiredInterfaces() public view override returns (uint256[] interfaces) { | |
| return [ | |
| Media.ID, | |
| Terminal.ID, | |
| Network.ID | |
| ]; | |
| } | |
| function getDebotInfo() public functionID(0xDEB) view override returns( | |
| string name, string version, string publisher, string key, string author, | |
| address support, string hello, string language, string dabi, bytes icon) { | |
| name = "Network Example"; | |
| version = "0.1.0"; | |
| publisher = "TON Labs"; | |
| key = "Example Debot for Network Interface"; | |
| author = "TON Labs"; | |
| support = address(0); | |
| hello = "Hello, I'm example DeBot."; | |
| language = "en"; | |
| dabi = m_debotAbi.get(); | |
| icon = ""; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment