├── .gitattributes ├── BURNER ├── BurnerDeployer.sol └── README.md ├── LICENSE ├── README.md ├── cpp ├── tokens-auth │ ├── AuthRoot.abi │ ├── AuthRoot.cpp │ ├── AuthRoot.hpp │ ├── AuthRoot.tvc │ ├── AuthWallet.abi │ ├── AuthWallet.cpp │ ├── AuthWallet.hpp │ ├── AuthWallet.tvc │ └── README.md ├── tokens-fungible │ ├── FlexWallet.abi │ ├── FlexWallet.hpp │ ├── FlexWallet.tvc │ ├── Makefile │ ├── README.md │ ├── RootTokenContract.abi │ ├── RootTokenContract.cpp │ ├── RootTokenContract.hpp │ ├── RootTokenContract.tvc │ ├── TONTokenWallet.abi │ ├── TONTokenWallet.cpp │ ├── TONTokenWallet.hpp │ ├── TONTokenWallet.tvc │ ├── Wrapper.abi │ ├── Wrapper.cpp │ ├── Wrapper.hpp │ └── Wrapper.tvc ├── tokens-nonfungible │ ├── README.md │ ├── RootTokenContractNF.abi │ ├── RootTokenContractNF.cpp │ ├── RootTokenContractNF.hpp │ ├── RootTokenContractNF.tvc │ ├── TONTokenWalletNF.abi │ ├── TONTokenWalletNF.cpp │ ├── TONTokenWalletNF.hpp │ └── TONTokenWalletNF.tvc └── tokens-utxo │ ├── README.md │ ├── RootTokenContractUTXO.abi │ ├── RootTokenContractUTXO.cpp │ ├── RootTokenContractUTXO.hpp │ ├── RootTokenContractUTXO.tvc │ ├── TONTokenWalletUTXO.abi │ ├── TONTokenWalletUTXO.cpp │ ├── TONTokenWalletUTXO.hpp │ └── TONTokenWalletUTXO.tvc ├── debots ├── AddressInput.sol ├── Debot.sol ├── Menu.sol ├── Sdk.sol ├── Terminal.sol └── msig │ ├── msigDebot2.abi.json │ ├── msigDebot2.sol │ └── msigDebot2.tvc ├── dens └── redens │ ├── README.md │ ├── debots.key.json │ ├── redens.abi.json │ ├── redens.sol │ ├── redens.tvc │ └── update.sh ├── governance └── SMV │ ├── Budget.abi │ ├── Budget.cpp │ ├── Budget.hpp │ ├── Budget.tvc │ ├── Contest.abi │ ├── Contest.cpp │ ├── Contest.tvc │ ├── DePool.hpp │ ├── Makefile │ ├── MultiBallot.abi │ ├── MultiBallot.cpp │ ├── MultiBallot.hpp │ ├── MultiBallot.tvc │ ├── ProposalRoot.abi │ ├── ProposalRoot.cpp │ ├── ProposalRoot.hpp │ ├── ProposalRoot.tvc │ ├── README.md │ ├── SMVDeBot │ ├── MultiBallot.abi │ ├── ProposalRoot.abi │ ├── SMVStats.abi │ ├── SuperRoot.abi │ ├── deployProposal │ │ ├── Debot.sol │ │ ├── deploy.sh │ │ ├── deployProposalDebot.abi.json │ │ ├── deployProposalDebot.sol │ │ └── deployProposalDebot.tvc │ ├── deployall.sh │ ├── msigHelper │ │ ├── Debot.sol │ │ ├── SafeMultisigWallet.abi.json │ │ ├── deploy.sh │ │ ├── msigHelperDebot.abi.json │ │ ├── msigHelperDebot.sol │ │ └── msigHelperDebot.tvc │ ├── multiballot │ │ ├── Debot.sol │ │ ├── MultiBallotDebot.abi.json │ │ ├── MultiBallotDebot.sol │ │ ├── MultiBallotDebot.tvc │ │ └── deploy.sh │ ├── proposalRoot │ │ ├── Debot.sol │ │ ├── deploy.sh │ │ ├── proposalRootDebot.abi.json │ │ ├── proposalRootDebot.sol │ │ └── proposalRootDebot.tvc │ ├── run.sh │ ├── smvStats │ │ ├── Debot.sol │ │ ├── deploy.sh │ │ ├── smvStatDebot.abi.json │ │ ├── smvStatDebot.sol │ │ └── smvStatDebot.tvc │ └── superRoot │ │ ├── Debot.sol │ │ ├── deploy.sh │ │ ├── superRootDebot.abi.json │ │ ├── superRootDebot.sol │ │ └── superRootDebot.tvc │ ├── SMVStats.abi │ ├── SMVStats.cpp │ ├── SMVStats.hpp │ ├── SMVStats.tvc │ ├── SuperRoot.abi │ ├── SuperRoot.cpp │ ├── SuperRoot.hpp │ ├── SuperRoot.tvc │ └── config.hpp └── solidity ├── contest ├── FreeTonContest.abi.json ├── FreeTonContest.sol ├── FreeTonContest.tvc ├── IBaseData.sol └── IContestData.sol ├── debots ├── Debot.sol ├── README.md ├── ludi │ ├── ludiDebot.abi.json │ ├── ludiDebot.sol │ └── ludiDebot.tvc └── msig │ ├── msigDebot.abi.json │ ├── msigDebot.sol │ └── msigDebot.tvc ├── depool ├── DePool.abi.json ├── DePool.sol ├── DePool.tvc ├── DePoolBase.sol ├── DePoolHelper.abi.json ├── DePoolHelper.sol ├── DePoolHelper.tvc ├── DePoolLib.sol ├── DePoolProxy.abi.json ├── DePoolProxy.sol ├── DePoolProxy.tvc ├── DePoolRounds.sol ├── IDePool.sol ├── IDePoolInfoGetter.abi.json ├── IDePoolInfoGetter.sol ├── IElector.sol ├── IParticipant.abi.json ├── IParticipant.sol ├── IProxy.sol ├── Participant.sol └── README.md ├── depress ├── DePress │ ├── DePress.abi.json │ ├── DePress.sol │ └── DePress.tvc ├── DePressDeBot │ ├── DePressDeBot.abi.json │ ├── DePressDeBot.sol │ ├── DePressDeBot.tvc │ ├── DePress_tvc.txt │ ├── Debot.sol │ ├── Transferable.sol │ ├── Upgradable.sol │ ├── deploy.sh │ └── itf │ │ ├── Base64.sol │ │ ├── Menu.sol │ │ ├── Msg.sol │ │ ├── Sdk.sol │ │ └── Terminal.sol └── DePressMemberDeBot │ ├── DePressMemberDeBot.abi.json │ ├── DePressMemberDeBot.sol │ ├── DePressMemberDeBot.tvc │ ├── DePress_tvc.txt │ ├── Debot.sol │ ├── Transferable.sol │ ├── Upgradable.sol │ ├── deploy.sh │ └── itf │ ├── AddressInput.sol │ ├── Base64.sol │ ├── Menu.sol │ ├── Sdk.sol │ └── Terminal.sol ├── dod ├── dod.abi.json ├── dod.sol ├── dod.tvc ├── dodDebot.abi.json ├── dodDebot.sol ├── dodDebot.tvc └── idod.sol ├── elector ├── Common.sol ├── Config.abi.json ├── Config.sol ├── Elector.abi.json ├── Elector.sol ├── Elector.tvc ├── IConfig.sol ├── IElector.sol └── IValidator.sol ├── safemultisig ├── FormalVerification │ └── About ├── README.md ├── SafeMultisigWallet.abi.json ├── SafeMultisigWallet.sol └── SafeMultisigWallet.tvc └── setcodemultisig ├── README.md ├── SetcodeMultisigWallet.abi.json ├── SetcodeMultisigWallet.sol └── SetcodeMultisigWallet.tvc /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /BURNER/BurnerDeployer.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.51.0; 2 | pragma AbiHeader expire; 3 | 4 | contract BurnerDeployer { 5 | 6 | modifier checkOwnerAndAccept { 7 | require(msg.pubkey() == tvm.pubkey(), 102); 8 | tvm.accept(); 9 | _; 10 | } 11 | 12 | function deploy() public checkOwnerAndAccept pure returns (address addr) { 13 | TvmBuilder code; 14 | code.storeUnsigned(0xFF00, 16); // SETCP0 15 | code.storeUnsigned(0, 8); // NOP 16 | TvmBuilder b; 17 | // _ split_depth:(Maybe (## 5)) special:(Maybe TickTock) 18 | // code:(Maybe ^Cell) data:(Maybe ^Cell) 19 | // library:(Maybe ^Cell) = StateInit; 20 | b.store(false, false, true, code.toCell(), false, false); 21 | TvmCell stateInit = b.toCell(); 22 | addr = address.makeAddrStd(-1, tvm.hash(stateInit)); 23 | addr.transfer({value: 0.1 ton, bounce: false, stateInit: stateInit}); 24 | } 25 | } -------------------------------------------------------------------------------- /BURNER/README.md: -------------------------------------------------------------------------------- 1 | # BURNER 2 | 3 | Address in mainnet: 4 | 5 | -1:efd5a14409a8a129686114fc092525fddd508f1ea56d1b649a3a695d3a5b188c 6 | 7 | NOTE1: The Burner smc is very simple, so it does not have ABI interface. 8 | 9 | Burner contains empty data and only 2 tvm instructions in the code: 10 | 11 | ```bash 12 | SETCP0 13 | NOP 14 | ``` 15 | 16 | Important: The Burner does not have any owner or keys. 17 | 18 | ### How to check that Burner has no keys. 19 | 20 | 1. Dump and decode the Burner state with the following command: 21 | 22 | ```bash 23 | tonos-cli -u main.ton.dev decode stateinit -1:efd5a14409a8a129686114fc092525fddd508f1ea56d1b649a3a695d3a5b188c 24 | ``` 25 | 26 | 2. Then deserialize `data` with: 27 | 28 | ```bash 29 | echo -n | base64 -d | xxd 30 | ``` 31 | 32 | Example: 33 | 34 | ```bash 35 | echo -n te6ccgEBAQEAAgAAAA== | base64 -d | xxd 36 | 00000000: b5ee 9c72 0101 0101 0002 0000 00 ...r......... 37 | ``` 38 | 39 | First 13 bytes is a boc header after which there is no data bytes, it means that there is no public key. 40 | 41 | ### Another way to check Burner data using tvm_linker 42 | 43 | ```bash 44 | tonos-cli -u main.ton.dev account -1:efd5a14409a8a129686114fc092525fddd508f1ea56d1b649a3a695d3a5b188c --dumptvc acc.tvc 45 | tvm_linker disasm dump acc.tvc 46 | 47 | ``` 48 | 49 | Example of tvm_linker output: 50 | 51 | ```bash 52 | $ tvm_linker disasm dump acc.tvc 53 | └ ff0000 54 | ``` 55 | 56 | Decoded Burner stateInit contains only the code cell with 2 instructions (ff00 - SETCP0, 00 - NOP) and no data cell. 57 | 58 | # How to build BurnerDeployer 59 | 60 | ## Prereq 61 | 62 | solc 0.51.0 63 | 64 | tvm_linker 0.13.83 65 | 66 | ## Compile 67 | 68 | ```bash 69 | tondev sol compile BurnerDeployer.sol 70 | ``` 71 | 72 | # How to deploy Burner 73 | 74 | ## 1) Generate address for `BurnerDeployer`: 75 | 76 | ```bash 77 | tonos-cli genaddr BurnerDeployer.tvc BurnerDeployer.abi.json --genkey BurnerDeployer.keys.json 78 | ``` 79 | ## 2) Send 1 token to generated address. 80 | 81 | ## 3) Deploy `BurnerDeployer`: 82 | 83 | ```bash 84 | tonos-cli deploy BurnerDeployer.tvc {} --abi BurnerDeployer.abi.json --sign BurnerDeployer.keys.json 85 | ``` 86 | 87 | ## 4) call `deploy` function: 88 | 89 | ```bash 90 | tonos-cli call deploy {} --abi BurnerDeployer.abi.json --sign BurnerDeployer.keys.json 91 | ``` 92 | - insert here address of the deployer. 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EverX Smart Contracts 2 | Smart contracts for Free TON blockchain. 3 | Solidity and C++ contracts and accompanying documentation are in their respective folders. 4 | 5 | **Some of the more commonly used contracts:** 6 | - [SafeMultisig Wallet](https://github.com/tonlabs/ton-labs-contracts/tree/master/solidity/safemultisig) - formally verified wallet recommended for validators 7 | - [SetcodeMultisig Wallet](https://github.com/tonlabs/ton-labs-contracts/tree/master/solidity/setcodemultisig) - a more advanced version of the wallet that allows to manage custodians 8 | - [DePool](https://github.com/tonlabs/ton-labs-contracts/tree/master/solidity/depool) - decentralized staking smart contract 9 | - [SMV](https://github.com/tonlabs/ton-labs-contracts/tree/master/governance/SMV) - advanced governance smart contracts 10 | - [DeBots](https://github.com/tonlabs/ton-labs-contracts/tree/master/debots) - decentralized bot interfaces to smart contracts on Free TON 11 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthRoot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"root_public_key", "type":"uint256" }, 15 | { "name":"root_owner", "type":"uint256" }, 16 | { "name":"wallet_code", "type":"cell" } 17 | ], 18 | "outputs": [ 19 | ], 20 | "id": "0xa" 21 | }, 22 | { 23 | "name": "deployWallet", 24 | "inputs": [ 25 | { "name":"_answer_id", "type":"uint32" }, 26 | { "name":"workchain_id", "type":"int8" }, 27 | { "name":"pubkey", "type":"uint256" }, 28 | { "name":"rightId", "type":"uint256" }, 29 | { "name":"grams", "type":"uint256" } 30 | ], 31 | "outputs": [ 32 | { "name":"value0", "type":"address" } 33 | ], 34 | "id": "0xb" 35 | }, 36 | { 37 | "name": "deployEmptyWallet", 38 | "inputs": [ 39 | { "name":"_answer_id", "type":"uint32" }, 40 | { "name":"workchain_id", "type":"int8" }, 41 | { "name":"pubkey", "type":"uint256" }, 42 | { "name":"grams", "type":"uint256" } 43 | ], 44 | "outputs": [ 45 | { "name":"value0", "type":"address" } 46 | ], 47 | "id": "0xc" 48 | }, 49 | { 50 | "name": "grant", 51 | "inputs": [ 52 | { "name":"dest", "type":"address" }, 53 | { "name":"rightId", "type":"uint256" }, 54 | { "name":"grams", "type":"uint256" } 55 | ], 56 | "outputs": [ 57 | ], 58 | "id": "0xd" 59 | }, 60 | { 61 | "name": "deny", 62 | "inputs": [ 63 | { "name":"dest", "type":"address" }, 64 | { "name":"rightId", "type":"uint256" }, 65 | { "name":"grams", "type":"uint256" } 66 | ], 67 | "outputs": [ 68 | ], 69 | "id": "0xe" 70 | }, 71 | { 72 | "name": "destroyWallet", 73 | "inputs": [ 74 | { "name":"dest", "type":"address" }, 75 | { "name":"grams", "type":"uint256" } 76 | ], 77 | "outputs": [ 78 | ], 79 | "id": "0xf" 80 | }, 81 | { 82 | "name": "destroyRoot", 83 | "inputs": [ 84 | { "name":"dest", "type":"address" } 85 | ], 86 | "outputs": [ 87 | ], 88 | "id": "0x10" 89 | }, 90 | { 91 | "name": "getName", 92 | "inputs": [ 93 | ], 94 | "outputs": [ 95 | { "name":"value0", "type":"bytes" } 96 | ], 97 | "id": "0x11" 98 | }, 99 | { 100 | "name": "getSymbol", 101 | "inputs": [ 102 | ], 103 | "outputs": [ 104 | { "name":"value0", "type":"bytes" } 105 | ], 106 | "id": "0x12" 107 | }, 108 | { 109 | "name": "getRootKey", 110 | "inputs": [ 111 | ], 112 | "outputs": [ 113 | { "name":"value0", "type":"uint256" } 114 | ], 115 | "id": "0x13" 116 | }, 117 | { 118 | "name": "getWalletCode", 119 | "inputs": [ 120 | ], 121 | "outputs": [ 122 | { "name":"value0", "type":"cell" } 123 | ], 124 | "id": "0x14" 125 | }, 126 | { 127 | "name": "getWalletAddress", 128 | "inputs": [ 129 | { "name":"workchain_id", "type":"int8" }, 130 | { "name":"pubkey", "type":"uint256" } 131 | ], 132 | "outputs": [ 133 | { "name":"value0", "type":"address" } 134 | ], 135 | "id": "0x15" 136 | } 137 | ], 138 | "events": [ 139 | ] 140 | } 141 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthRoot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AuthWallet.hpp" 4 | 5 | namespace tvm { namespace schema { 6 | 7 | // ===== Auth Root Contract ===== // 8 | __interface IAuthRoot { 9 | 10 | // expected offchain constructor execution 11 | [[external, dyn_chain_parse]] 12 | void constructor(bytes name, bytes symbol, 13 | uint256 root_public_key, uint256 root_owner, cell wallet_code) = 10; 14 | 15 | [[internal, external, noaccept, dyn_chain_parse, answer_id]] 16 | address deployWallet(int8 workchain_id, uint256 pubkey, 17 | RightId rightId, WalletGramsType grams) = 11; 18 | 19 | [[internal, noaccept, dyn_chain_parse, answer_id]] 20 | address deployEmptyWallet(int8 workchain_id, uint256 pubkey, 21 | WalletGramsType grams) = 12; 22 | 23 | [[internal, external, noaccept, dyn_chain_parse]] 24 | void grant(address dest, RightId rightId, WalletGramsType grams) = 13; 25 | 26 | [[internal, external, noaccept, dyn_chain_parse]] 27 | void deny(address dest, RightId rightId, WalletGramsType grams) = 14; 28 | 29 | [[internal, external, noaccept, dyn_chain_parse]] 30 | void destroyWallet(address dest, WalletGramsType grams) = 15; 31 | 32 | // Destroy root and return all rest funds to dest 33 | [[internal, external, noaccept, dyn_chain_parse]] 34 | void destroyRoot(address dest) = 16; 35 | 36 | [[getter]] 37 | bytes getName() = 17; 38 | 39 | [[getter]] 40 | bytes getSymbol() = 18; 41 | 42 | [[getter]] 43 | uint256 getRootKey() = 19; 44 | 45 | [[getter]] 46 | cell getWalletCode() = 20; 47 | 48 | [[getter]] 49 | address getWalletAddress(int8 workchain_id, uint256 pubkey) = 21; 50 | }; 51 | 52 | struct DAuthRoot { 53 | bytes name_; 54 | bytes symbol_; 55 | uint256 root_public_key_; 56 | std::optional
owner_address_; 57 | cell wallet_code_; 58 | Grams start_balance_; 59 | }; 60 | 61 | struct EAuthRoot { 62 | }; 63 | 64 | }} // namespace tvm::schema 65 | 66 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthRoot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-auth/AuthRoot.tvc -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthWallet.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"root_public_key", "type":"uint256" }, 15 | { "name":"wallet_public_key", "type":"uint256" }, 16 | { "name":"root_address", "type":"address" }, 17 | { "name":"code", "type":"cell" } 18 | ], 19 | "outputs": [ 20 | ], 21 | "id": "0xa" 22 | }, 23 | { 24 | "name": "accept", 25 | "inputs": [ 26 | { "name":"rightId", "type":"uint256" } 27 | ], 28 | "outputs": [ 29 | ], 30 | "id": "0xb" 31 | }, 32 | { 33 | "name": "deny", 34 | "inputs": [ 35 | { "name":"rightId", "type":"uint256" } 36 | ], 37 | "outputs": [ 38 | ], 39 | "id": "0xc" 40 | }, 41 | { 42 | "name": "destroy", 43 | "inputs": [ 44 | ], 45 | "outputs": [ 46 | ], 47 | "id": "0xd" 48 | }, 49 | { 50 | "name": "getName", 51 | "inputs": [ 52 | ], 53 | "outputs": [ 54 | { "name":"value0", "type":"bytes" } 55 | ], 56 | "id": "0xe" 57 | }, 58 | { 59 | "name": "getSymbol", 60 | "inputs": [ 61 | ], 62 | "outputs": [ 63 | { "name":"value0", "type":"bytes" } 64 | ], 65 | "id": "0xf" 66 | }, 67 | { 68 | "name": "getWalletKey", 69 | "inputs": [ 70 | ], 71 | "outputs": [ 72 | { "name":"value0", "type":"uint256" } 73 | ], 74 | "id": "0x10" 75 | }, 76 | { 77 | "name": "getRootAddress", 78 | "inputs": [ 79 | ], 80 | "outputs": [ 81 | { "name":"value0", "type":"address" } 82 | ], 83 | "id": "0x11" 84 | }, 85 | { 86 | "name": "getRightsCount", 87 | "inputs": [ 88 | ], 89 | "outputs": [ 90 | { "name":"value0", "type":"uint256" } 91 | ], 92 | "id": "0x12" 93 | }, 94 | { 95 | "name": "getRightByIndex", 96 | "inputs": [ 97 | { "name":"index", "type":"uint256" } 98 | ], 99 | "outputs": [ 100 | { "name":"value0", "type":"uint256" } 101 | ], 102 | "id": "0x13" 103 | }, 104 | { 105 | "name": "getRights", 106 | "inputs": [ 107 | ], 108 | "outputs": [ 109 | { "name":"value0", "type":"uint256[]" } 110 | ], 111 | "id": "0x14" 112 | } 113 | ], 114 | "events": [ 115 | ] 116 | } 117 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthWallet.cpp: -------------------------------------------------------------------------------- 1 | #include "AuthWallet.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace tvm; 9 | using namespace schema; 10 | 11 | class AuthWallet final : public smart_interface, public DAuthWallet { 12 | public: 13 | struct error_code : tvm::error_code { 14 | static constexpr unsigned message_sender_is_not_my_root = 100; 15 | }; 16 | 17 | __always_inline 18 | void constructor(bytes name, bytes symbol, 19 | uint256 root_public_key, uint256 wallet_public_key, 20 | address root_address, cell code) { 21 | name_ = name; 22 | symbol_ = symbol; 23 | root_public_key_ = root_public_key; 24 | wallet_public_key_ = wallet_public_key; 25 | root_address_ = root_address; 26 | } 27 | 28 | __always_inline 29 | void accept(RightId rightId) { 30 | require(root_address_ == int_sender(), 31 | error_code::message_sender_is_not_my_root); 32 | tvm_accept(); 33 | 34 | if (rightId) 35 | rights_.insert(rightId); 36 | } 37 | 38 | __always_inline 39 | void deny(RightId rightId) { 40 | require(root_address_ == int_sender(), 41 | error_code::message_sender_is_not_my_root); 42 | tvm_accept(); 43 | 44 | if (rightId) 45 | rights_.erase(rightId); 46 | } 47 | 48 | __always_inline 49 | void destroy() { 50 | require(root_address_ == int_sender(), 51 | error_code::message_sender_is_not_my_root); 52 | tvm_accept(); 53 | auto empty_cell = builder().endc(); 54 | tvm_transfer(root_address_, 0, false, 55 | SEND_ALL_GAS | SENDER_WANTS_TO_PAY_FEES_SEPARATELY | DELETE_ME_IF_I_AM_EMPTY | IGNORE_ACTION_ERRORS, 56 | empty_cell); 57 | } 58 | 59 | // =============== getters ================== // 60 | __always_inline 61 | bytes getName() { 62 | return name_; 63 | } 64 | __always_inline 65 | bytes getSymbol() { 66 | return symbol_; 67 | } 68 | __always_inline 69 | uint256 getWalletKey() { 70 | return wallet_public_key_; 71 | } 72 | __always_inline 73 | address getRootAddress() { 74 | return root_address_; 75 | } 76 | __always_inline 77 | RightsType getRightsCount() { 78 | return RightsType(rights_.size().get()); 79 | } 80 | __always_inline 81 | RightId getRightByIndex(RightsType index) { 82 | require(index < rights_.size(), error_code::iterator_overflow); 83 | return *std::next(rights_.begin(), index.get()); 84 | } 85 | __always_inline 86 | dict_array getRights() { 87 | return dict_array(rights_.begin(), rights_.end()); 88 | } 89 | 90 | // default processing of unknown messages 91 | __always_inline static int _fallback(cell msg, slice msg_body) { 92 | return 0; 93 | } 94 | 95 | // =============== Support functions ================== // 96 | DEFAULT_SUPPORT_FUNCTIONS(IAuthWallet, wallet_replay_protection_t) 97 | }; 98 | 99 | DEFINE_JSON_ABI(IAuthWallet, DAuthWallet, EAuthWallet); 100 | 101 | // ----------------------------- Main entry functions ---------------------- // 102 | DEFAULT_MAIN_ENTRY_FUNCTIONS(AuthWallet, IAuthWallet, DAuthWallet, WALLET_TIMESTAMP_DELAY) 103 | 104 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthWallet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace tvm { namespace schema { 11 | 12 | using WalletGramsType = uint256; 13 | using RightsType = uint256; 14 | using RightId = uint256; 15 | 16 | static constexpr unsigned WALLET_TIMESTAMP_DELAY = 1800; 17 | using wallet_replay_protection_t = replay_attack_protection::timestamp; 18 | 19 | // ===== Auth wallet ===== // 20 | __interface IAuthWallet { 21 | 22 | // expected offchain constructor execution 23 | [[internal, external, dyn_chain_parse]] 24 | void constructor(bytes name, bytes symbol, 25 | uint256 root_public_key, uint256 wallet_public_key, 26 | address root_address, cell code) = 10; 27 | 28 | // Receive right id from root 29 | [[internal, noaccept]] 30 | void accept(RightId rightId) = 11; 31 | 32 | // Remove right id command from root 33 | [[internal, noaccept]] 34 | void deny(RightId rightId) = 12; 35 | 36 | // Destroy wallet and return all rest funds back to root 37 | [[internal, noaccept]] 38 | void destroy() = 13; 39 | 40 | // ===== getters ===== // 41 | [[getter]] 42 | bytes getName() = 14; 43 | 44 | [[getter]] 45 | bytes getSymbol() = 15; 46 | 47 | [[getter]] 48 | uint256 getWalletKey() = 16; 49 | 50 | [[getter]] 51 | address getRootAddress() = 17; 52 | 53 | [[getter]] 54 | RightsType getRightsCount() = 18; 55 | 56 | [[getter]] 57 | RightId getRightByIndex(RightsType index) = 19; 58 | 59 | [[getter]] 60 | dict_array getRights() = 20; 61 | }; 62 | 63 | struct DAuthWallet { 64 | bytes name_; 65 | bytes symbol_; 66 | uint256 root_public_key_; 67 | uint256 wallet_public_key_; 68 | address root_address_; 69 | dict_set rights_; 70 | }; 71 | 72 | struct EAuthWallet { 73 | }; 74 | 75 | // Prepare Auth Wallet StateInit structure and expected contract address (hash from StateInit) 76 | inline 77 | std::pair prepare_wallet_state_init_and_addr(DAuthWallet wallet_data, cell wallet_code) { 78 | cell wallet_data_cl = 79 | prepare_persistent_data( 80 | wallet_replay_protection_t::init(), wallet_data); 81 | StateInit wallet_init { 82 | /*split_depth*/{}, /*special*/{}, 83 | wallet_code, wallet_data_cl, /*library*/{} 84 | }; 85 | cell wallet_init_cl = build(wallet_init).make_cell(); 86 | return { wallet_init, uint256(tvm_hash(wallet_init_cl)) }; 87 | } 88 | 89 | }} // namespace tvm::schema 90 | 91 | -------------------------------------------------------------------------------- /cpp/tokens-auth/AuthWallet.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-auth/AuthWallet.tvc -------------------------------------------------------------------------------- /cpp/tokens-fungible/FlexWallet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef TIP3_ENABLE_LEND_OWNERSHIP 4 | #define TIP3_ENABLE_LEND_OWNERSHIP 5 | #endif 6 | #ifndef TIP3_ENABLE_BURN 7 | #define TIP3_ENABLE_BURN 8 | #endif 9 | 10 | #include "TONTokenWallet.hpp" 11 | 12 | -------------------------------------------------------------------------------- /cpp/tokens-fungible/FlexWallet.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-fungible/FlexWallet.tvc -------------------------------------------------------------------------------- /cpp/tokens-fungible/Makefile: -------------------------------------------------------------------------------- 1 | all: FlexWallet.tvc TONTokenWallet.tvc RootTokenContract.tvc Wrapper.tvc 2 | 3 | FlexWallet.tvc: TONTokenWallet.cpp TONTokenWallet.hpp 4 | clang TONTokenWallet.cpp -DTIP3_ENABLE_LEND_OWNERSHIP -DTIP3_ENABLE_BURN -mtvm-refunc -o FlexWallet.tvc 5 | 6 | TONTokenWallet.tvc: TONTokenWallet.cpp TONTokenWallet.hpp 7 | clang TONTokenWallet.cpp -DTIP3_ENABLE_EXTERNAL -DTIP3_ENABLE_ALLOWANCE -DTIP3_IMPROVED_TRANSFER -mtvm-refunc -o TONTokenWallet.tvc 8 | 9 | RootTokenContract.tvc: RootTokenContract.cpp RootTokenContract.hpp TONTokenWallet.hpp 10 | clang RootTokenContract.cpp -DTIP3_ENABLE_EXTERNAL -DTIP3_ENABLE_ALLOWANCE -DTIP3_IMPROVED_TRANSFER -o RootTokenContract.tvc 11 | 12 | Wrapper.tvc: Wrapper.cpp Wrapper.hpp TONTokenWallet.hpp 13 | clang Wrapper.cpp -o Wrapper.tvc -DTIP3_ENABLE_EXTERNAL -DTIP3_ENABLE_ALLOWANCE -DTIP3_IMPROVED_TRANSFER 14 | 15 | clean: 16 | rm -rf *.tvc 17 | rm -rf *.abi 18 | 19 | -------------------------------------------------------------------------------- /cpp/tokens-fungible/RootTokenContract.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TONTokenWallet.hpp" 4 | 5 | namespace tvm { inline namespace schema { 6 | 7 | static constexpr unsigned ROOT_TIMESTAMP_DELAY = 1800; 8 | using root_replay_protection_t = replay_attack_protection::timestamp; 9 | 10 | // ===== Root Token Contract ===== // 11 | __interface IRootTokenContract { 12 | 13 | // expected offchain constructor execution 14 | [[internal, external, dyn_chain_parse]] 15 | void constructor( 16 | string name, 17 | string symbol, 18 | uint8 decimals, 19 | uint256 root_public_key, 20 | address root_owner, 21 | uint128 total_supply 22 | ) = 10; 23 | 24 | [[internal, external, noaccept, dyn_chain_parse, answer_id]] 25 | bool_t setWalletCode(cell wallet_code) = 11; 26 | 27 | // Should be provided pubkey (for external owned wallet) or std addr (for internal owned wallet). 28 | [[internal, external, noaccept, dyn_chain_parse, answer_id]] 29 | address deployWallet( 30 | uint256 pubkey, 31 | address internal_owner, 32 | uint128 tokens, 33 | uint128 grams 34 | ) = 12; 35 | 36 | // Anyone may request to deploy an empty wallet 37 | [[internal, noaccept, dyn_chain_parse, answer_id]] 38 | address deployEmptyWallet( 39 | uint256 pubkey, 40 | address internal_owner, 41 | uint128 grams 42 | ) = 13; 43 | 44 | [[internal, external, noaccept, dyn_chain_parse, answer_id]] 45 | void grant( 46 | address dest, 47 | uint128 tokens, 48 | uint128 grams 49 | ) = 14; 50 | 51 | [[internal, external, noaccept, dyn_chain_parse, answer_id]] 52 | bool_t mint(uint128 tokens) = 15; 53 | 54 | [[internal, noaccept, answer_id]] 55 | uint128 requestTotalGranted() = 16; 56 | 57 | [[getter]] 58 | string getName() = 17; 59 | 60 | [[getter]] 61 | string getSymbol() = 18; 62 | 63 | [[getter]] 64 | uint8 getDecimals() = 19; 65 | 66 | [[getter]] 67 | uint256 getRootKey() = 20; 68 | 69 | [[getter]] 70 | uint128 getTotalSupply() = 21; 71 | 72 | [[getter]] 73 | uint128 getTotalGranted() = 22; 74 | 75 | [[getter]] 76 | bool_t hasWalletCode() = 23; 77 | 78 | [[getter]] 79 | cell getWalletCode() = 24; 80 | 81 | [[getter, dyn_chain_parse]] 82 | address getWalletAddress(uint256 pubkey, address owner) = 25; 83 | 84 | [[getter]] 85 | uint256 getWalletCodeHash() = 26; 86 | }; 87 | using IRootTokenContractPtr = handle; 88 | 89 | struct DRootTokenContract { 90 | string name_; 91 | string symbol_; 92 | uint8 decimals_; 93 | uint256 root_public_key_; 94 | uint128 total_supply_; 95 | uint128 total_granted_; 96 | optcell wallet_code_; 97 | std::optional
owner_address_; 98 | Grams start_balance_; 99 | }; 100 | 101 | struct ERootTokenContract { 102 | }; 103 | 104 | // Prepare Root StateInit structure and expected contract address (hash from StateInit) 105 | inline 106 | std::pair prepare_root_state_init_and_addr(cell root_code, DRootTokenContract root_data) { 107 | cell root_data_cl = 108 | prepare_persistent_data( 109 | root_replay_protection_t::init(), root_data); 110 | StateInit root_init { 111 | /*split_depth*/{}, /*special*/{}, 112 | root_code, root_data_cl, /*library*/{} 113 | }; 114 | cell root_init_cl = build(root_init).make_cell(); 115 | return { root_init, uint256(tvm_hash(root_init_cl)) }; 116 | } 117 | 118 | }} // namespace tvm::schema 119 | 120 | -------------------------------------------------------------------------------- /cpp/tokens-fungible/RootTokenContract.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-fungible/RootTokenContract.tvc -------------------------------------------------------------------------------- /cpp/tokens-fungible/TONTokenWallet.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-fungible/TONTokenWallet.tvc -------------------------------------------------------------------------------- /cpp/tokens-fungible/Wrapper.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "version": "2.1.0", 4 | "header": [ 5 | "pubkey", 6 | "time", 7 | "expire" 8 | ], 9 | "functions": [ 10 | { 11 | "name": "init", 12 | "inputs": [ 13 | { "name":"_answer_id", "type":"uint32" }, 14 | { "name":"external_wallet", "type":"address" } 15 | ], 16 | "outputs": [ 17 | { "name":"value0", "type":"bool" } 18 | ] 19 | }, 20 | { 21 | "name": "setInternalWalletCode", 22 | "inputs": [ 23 | { "name":"_answer_id", "type":"uint32" }, 24 | { "name":"wallet_code", "type":"cell" } 25 | ], 26 | "outputs": [ 27 | { "name":"value0", "type":"bool" } 28 | ] 29 | }, 30 | { 31 | "name": "deployEmptyWallet", 32 | "inputs": [ 33 | { "name":"_answer_id", "type":"uint32" }, 34 | { "name":"pubkey", "type":"uint256" }, 35 | { "name":"internal_owner", "type":"address" }, 36 | { "name":"grams", "type":"uint128" } 37 | ], 38 | "outputs": [ 39 | { "name":"value0", "type":"address" } 40 | ] 41 | }, 42 | { 43 | "name": "onTip3Transfer", 44 | "inputs": [ 45 | { "name":"_answer_id", "type":"uint32" }, 46 | { "name":"answer_addr", "type":"address" }, 47 | { "name":"balance", "type":"uint128" }, 48 | { "name":"new_tokens", "type":"uint128" }, 49 | { "name":"pubkey", "type":"uint256" }, 50 | { "name":"internal_owner", "type":"address" }, 51 | { "name":"payload", "type":"cell" } 52 | ], 53 | "outputs": [ 54 | { "name":"err_code", "type":"uint32" }, 55 | { "name":"flex_wallet", "type":"address" } 56 | ], 57 | "id": "0xca" 58 | }, 59 | { 60 | "name": "burn", 61 | "inputs": [ 62 | { "name":"answer_addr", "type":"address" }, 63 | { "name":"sender_pubkey", "type":"uint256" }, 64 | { "name":"sender_owner", "type":"address" }, 65 | { "name":"out_pubkey", "type":"uint256" }, 66 | { "name":"out_internal_owner", "type":"address" }, 67 | { "name":"tokens", "type":"uint128" } 68 | ], 69 | "outputs": [ 70 | ] 71 | }, 72 | { 73 | "name": "requestTotalGranted", 74 | "inputs": [ 75 | { "name":"_answer_id", "type":"uint32" } 76 | ], 77 | "outputs": [ 78 | { "name":"value0", "type":"uint128" } 79 | ] 80 | }, 81 | { 82 | "name": "getDetails", 83 | "inputs": [ 84 | ], 85 | "outputs": [ 86 | { "name":"name", "type":"string" }, 87 | { "name":"symbol", "type":"string" }, 88 | { "name":"decimals", "type":"uint8" }, 89 | { "name":"root_public_key", "type":"uint256" }, 90 | { "name":"total_granted", "type":"uint128" }, 91 | { "name":"wallet_code", "type":"cell" }, 92 | { "name":"owner_address", "type":"address" }, 93 | { "name":"external_wallet", "type":"address" } 94 | ] 95 | }, 96 | { 97 | "name": "hasInternalWalletCode", 98 | "inputs": [ 99 | ], 100 | "outputs": [ 101 | { "name":"value0", "type":"bool" } 102 | ] 103 | }, 104 | { 105 | "name": "getWalletAddress", 106 | "inputs": [ 107 | { "name":"pubkey", "type":"uint256" }, 108 | { "name":"owner", "type":"address" } 109 | ], 110 | "outputs": [ 111 | { "name":"value0", "type":"address" } 112 | ] 113 | } 114 | ], 115 | "fields": [ 116 | { "name":"__uninitialized", "type":"bool" }, 117 | { "name":"name_", "type":"string" }, 118 | { "name":"symbol_", "type":"string" }, 119 | { "name":"decimals_", "type":"uint8" }, 120 | { "name":"workchain_id_", "type":"int8" }, 121 | { "name":"root_public_key_", "type":"uint256" }, 122 | { "name":"total_granted_", "type":"uint128" }, 123 | { "components":[ 124 | { "name":"dict_", "type":"cell" } 125 | ], "name":"internal_wallet_code_", "type":"tuple" }, 126 | { "name":"owner_address_", "type":"optional(address)" }, 127 | { "name":"start_balance_", "type":"varuint16" }, 128 | { "components":[ 129 | { "name":"addr_", "type":"address" } 130 | ], "name":"external_wallet_", "type":"optional(tuple)" } 131 | ], 132 | "events": [ 133 | ] 134 | } 135 | -------------------------------------------------------------------------------- /cpp/tokens-fungible/Wrapper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TONTokenWallet.hpp" 4 | 5 | namespace tvm { inline namespace schema { 6 | 7 | static constexpr unsigned WRAPPER_TIMESTAMP_DELAY = 1800; 8 | using wrapper_replay_protection_t = replay_attack_protection::timestamp; 9 | 10 | struct WrapperRet { 11 | uint32 err_code; 12 | address flex_wallet; 13 | }; 14 | 15 | struct FLeXDeployWalletArgs { 16 | uint256 pubkey; 17 | address internal_owner; 18 | uint128 grams; 19 | }; 20 | 21 | struct wrapper_details_info { 22 | string name; 23 | string symbol; 24 | uint8 decimals; 25 | uint256 root_public_key; 26 | uint128 total_granted; 27 | cell wallet_code; 28 | address owner_address; 29 | address external_wallet; 30 | }; 31 | 32 | // ===== FLeX Wrapper Contract ===== // 33 | __interface IWrapper { 34 | 35 | [[internal, external, dyn_chain_parse, answer_id]] 36 | bool_t init(address external_wallet); 37 | 38 | [[internal, external, noaccept, answer_id]] 39 | bool_t setInternalWalletCode(cell wallet_code); 40 | 41 | [[internal, noaccept, dyn_chain_parse, answer_id]] 42 | address deployEmptyWallet( 43 | uint256 pubkey, 44 | address internal_owner, 45 | uint128 grams 46 | ); 47 | 48 | // Notification about incoming tokens from Wrapper owned external wallet 49 | [[internal, noaccept, answer_id]] 50 | WrapperRet onTip3Transfer( 51 | address answer_addr, 52 | uint128 balance, 53 | uint128 new_tokens, 54 | uint256 pubkey, 55 | address internal_owner, 56 | cell payload 57 | ) = 202; 58 | 59 | [[internal, noaccept]] 60 | void burn( 61 | address answer_addr, 62 | uint256 sender_pubkey, 63 | address sender_owner, 64 | uint256 out_pubkey, 65 | address out_internal_owner, 66 | uint128 tokens 67 | ); 68 | 69 | [[internal, noaccept, answer_id]] 70 | uint128 requestTotalGranted(); 71 | 72 | [[getter]] 73 | wrapper_details_info getDetails(); 74 | 75 | [[getter]] 76 | bool_t hasInternalWalletCode(); 77 | 78 | [[getter, dyn_chain_parse]] 79 | address getWalletAddress(uint256 pubkey, address owner); 80 | }; 81 | using IWrapperPtr = handle; 82 | 83 | struct DWrapper { 84 | string name_; 85 | string symbol_; 86 | uint8 decimals_; 87 | int8 workchain_id_; 88 | uint256 root_public_key_; 89 | uint128 total_granted_; 90 | optcell internal_wallet_code_; 91 | std::optional
owner_address_; 92 | Grams start_balance_; 93 | std::optional external_wallet_; 94 | }; 95 | 96 | struct EWrapper { 97 | }; 98 | 99 | // Prepare Wrapper StateInit structure and expected contract address (hash from StateInit) 100 | inline 101 | std::pair prepare_wrapper_state_init_and_addr(cell wrapper_code, DWrapper wrapper_data) { 102 | cell wrapper_data_cl = 103 | prepare_persistent_data( 104 | wrapper_replay_protection_t::init(), wrapper_data); 105 | StateInit wrapper_init { 106 | /*split_depth*/{}, /*special*/{}, 107 | wrapper_code, wrapper_data_cl, /*library*/{} 108 | }; 109 | cell wrapper_init_cl = build(wrapper_init).make_cell(); 110 | return { wrapper_init, uint256(tvm_hash(wrapper_init_cl)) }; 111 | } 112 | 113 | }} // namespace tvm::schema 114 | 115 | -------------------------------------------------------------------------------- /cpp/tokens-fungible/Wrapper.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-fungible/Wrapper.tvc -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/RootTokenContractNF.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"decimals", "type":"uint8" }, 15 | { "name":"root_public_key", "type":"uint256" }, 16 | { "name":"wallet_code", "type":"cell" } 17 | ], 18 | "outputs": [ 19 | ], 20 | "id": "0xb" 21 | }, 22 | { 23 | "name": "deployWallet", 24 | "inputs": [ 25 | { "name":"workchain_id", "type":"int8" }, 26 | { "name":"pubkey", "type":"uint256" }, 27 | { "name":"tokenId", "type":"uint128" }, 28 | { "name":"grams", "type":"uint128" } 29 | ], 30 | "outputs": [ 31 | { "name":"value0", "type":"address" } 32 | ], 33 | "id": "0xc" 34 | }, 35 | { 36 | "name": "grant", 37 | "inputs": [ 38 | { "name":"dest", "type":"address" }, 39 | { "name":"tokenId", "type":"uint128" }, 40 | { "name":"grams", "type":"uint128" } 41 | ], 42 | "outputs": [ 43 | ], 44 | "id": "0xd" 45 | }, 46 | { 47 | "name": "mint", 48 | "inputs": [ 49 | { "name":"tokenId", "type":"uint128" } 50 | ], 51 | "outputs": [ 52 | { "name":"value0", "type":"uint128" } 53 | ], 54 | "id": "0xe" 55 | }, 56 | { 57 | "name": "getName", 58 | "inputs": [ 59 | ], 60 | "outputs": [ 61 | { "name":"value0", "type":"bytes" } 62 | ], 63 | "id": "0xf" 64 | }, 65 | { 66 | "name": "getSymbol", 67 | "inputs": [ 68 | ], 69 | "outputs": [ 70 | { "name":"value0", "type":"bytes" } 71 | ], 72 | "id": "0x10" 73 | }, 74 | { 75 | "name": "getDecimals", 76 | "inputs": [ 77 | ], 78 | "outputs": [ 79 | { "name":"value0", "type":"uint8" } 80 | ], 81 | "id": "0x11" 82 | }, 83 | { 84 | "name": "getRootKey", 85 | "inputs": [ 86 | ], 87 | "outputs": [ 88 | { "name":"value0", "type":"uint256" } 89 | ], 90 | "id": "0x12" 91 | }, 92 | { 93 | "name": "getTotalSupply", 94 | "inputs": [ 95 | ], 96 | "outputs": [ 97 | { "name":"value0", "type":"uint128" } 98 | ], 99 | "id": "0x13" 100 | }, 101 | { 102 | "name": "getTotalGranted", 103 | "inputs": [ 104 | ], 105 | "outputs": [ 106 | { "name":"value0", "type":"uint128" } 107 | ], 108 | "id": "0x14" 109 | }, 110 | { 111 | "name": "getWalletCode", 112 | "inputs": [ 113 | ], 114 | "outputs": [ 115 | { "name":"value0", "type":"cell" } 116 | ], 117 | "id": "0x15" 118 | }, 119 | { 120 | "name": "getLastMintedToken", 121 | "inputs": [ 122 | ], 123 | "outputs": [ 124 | { "name":"value0", "type":"uint128" } 125 | ], 126 | "id": "0x16" 127 | }, 128 | { 129 | "name": "getWalletAddress", 130 | "inputs": [ 131 | { "name":"workchain_id", "type":"int8" }, 132 | { "name":"pubkey", "type":"uint256" } 133 | ], 134 | "outputs": [ 135 | { "name":"value0", "type":"address" } 136 | ], 137 | "id": "0x17" 138 | } 139 | ], 140 | "events": [ 141 | ] 142 | } 143 | -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/RootTokenContractNF.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TONTokenWalletNF.hpp" 4 | 5 | namespace tvm { namespace schema { 6 | 7 | // ===== Root Token Contract (Non-fungible) ===== // 8 | __interface IRootTokenContract { 9 | 10 | // expected offchain constructor execution 11 | __attribute__((internal, external, dyn_chain_parse)) 12 | void constructor(bytes name, bytes symbol, uint8 decimals, 13 | uint256 root_public_key, cell wallet_code) = 11; 14 | 15 | __attribute__((external, noaccept, dyn_chain_parse)) 16 | lazy deployWallet(int8 workchain_id, uint256 pubkey, TokenId tokenId, WalletGramsType grams) = 12; 17 | 18 | __attribute__((external, noaccept, dyn_chain_parse)) 19 | void grant(lazy dest, TokenId tokenId, WalletGramsType grams) = 13; 20 | 21 | __attribute__((external, noaccept, dyn_chain_parse)) 22 | TokenId mint(TokenId tokenId) = 14; 23 | 24 | __attribute__((getter)) 25 | bytes getName() = 15; 26 | 27 | __attribute__((getter)) 28 | bytes getSymbol() = 16; 29 | 30 | __attribute__((getter)) 31 | uint8 getDecimals() = 17; 32 | 33 | __attribute__((getter)) 34 | uint256 getRootKey() = 18; 35 | 36 | __attribute__((getter)) 37 | TokensType getTotalSupply() = 19; 38 | 39 | __attribute__((getter)) 40 | TokensType getTotalGranted() = 20; 41 | 42 | __attribute__((getter)) 43 | cell getWalletCode() = 21; 44 | 45 | __attribute__((getter)) 46 | TokenId getLastMintedToken() = 22; 47 | 48 | __attribute__((getter)) 49 | lazy getWalletAddress(int8 workchain_id, uint256 pubkey) = 23; 50 | }; 51 | 52 | struct DRootTokenContract { 53 | bytes name_; 54 | bytes symbol_; 55 | uint8 decimals_; 56 | uint256 root_public_key_; 57 | TokensType total_supply_; 58 | TokensType total_granted_; 59 | cell wallet_code_; 60 | dict_set tokens_; 61 | }; 62 | 63 | struct ERootTokenContract { 64 | }; 65 | 66 | }} // namespace tvm::schema 67 | 68 | -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/RootTokenContractNF.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-nonfungible/RootTokenContractNF.tvc -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/TONTokenWalletNF.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"decimals", "type":"uint8" }, 15 | { "name":"root_public_key", "type":"uint256" }, 16 | { "name":"wallet_public_key", "type":"uint256" }, 17 | { "name":"root_address", "type":"address" }, 18 | { "name":"code", "type":"cell" } 19 | ], 20 | "outputs": [ 21 | ], 22 | "id": "0xb" 23 | }, 24 | { 25 | "name": "transfer", 26 | "inputs": [ 27 | { "name":"dest", "type":"address" }, 28 | { "name":"tokenId", "type":"uint128" }, 29 | { "name":"grams", "type":"uint128" } 30 | ], 31 | "outputs": [ 32 | ], 33 | "id": "0xc" 34 | }, 35 | { 36 | "name": "accept", 37 | "inputs": [ 38 | { "name":"tokenId", "type":"uint128" } 39 | ], 40 | "outputs": [ 41 | ], 42 | "id": "0xd" 43 | }, 44 | { 45 | "name": "internalTransfer", 46 | "inputs": [ 47 | { "name":"tokenId", "type":"uint128" }, 48 | { "name":"pubkey", "type":"uint256" } 49 | ], 50 | "outputs": [ 51 | ], 52 | "id": "0xe" 53 | }, 54 | { 55 | "name": "getName", 56 | "inputs": [ 57 | ], 58 | "outputs": [ 59 | { "name":"value0", "type":"bytes" } 60 | ], 61 | "id": "0xf" 62 | }, 63 | { 64 | "name": "getSymbol", 65 | "inputs": [ 66 | ], 67 | "outputs": [ 68 | { "name":"value0", "type":"bytes" } 69 | ], 70 | "id": "0x10" 71 | }, 72 | { 73 | "name": "getDecimals", 74 | "inputs": [ 75 | ], 76 | "outputs": [ 77 | { "name":"value0", "type":"uint8" } 78 | ], 79 | "id": "0x11" 80 | }, 81 | { 82 | "name": "getBalance", 83 | "inputs": [ 84 | ], 85 | "outputs": [ 86 | { "name":"value0", "type":"uint128" } 87 | ], 88 | "id": "0x12" 89 | }, 90 | { 91 | "name": "getWalletKey", 92 | "inputs": [ 93 | ], 94 | "outputs": [ 95 | { "name":"value0", "type":"uint256" } 96 | ], 97 | "id": "0x13" 98 | }, 99 | { 100 | "name": "getRootAddress", 101 | "inputs": [ 102 | ], 103 | "outputs": [ 104 | { "name":"value0", "type":"address" } 105 | ], 106 | "id": "0x14" 107 | }, 108 | { 109 | "name": "allowance", 110 | "inputs": [ 111 | ], 112 | "outputs": [ 113 | { "name":"spender", "type":"address" }, 114 | { "name":"allowedToken", "type":"uint128" } 115 | ], 116 | "id": "0x15" 117 | }, 118 | { 119 | "name": "getTokenByIndex", 120 | "inputs": [ 121 | { "name":"index", "type":"uint128" } 122 | ], 123 | "outputs": [ 124 | { "name":"value0", "type":"uint128" } 125 | ], 126 | "id": "0x16" 127 | }, 128 | { 129 | "name": "getApproved", 130 | "inputs": [ 131 | { "name":"tokenId", "type":"uint128" } 132 | ], 133 | "outputs": [ 134 | { "name":"value0", "type":"address" } 135 | ], 136 | "id": "0x17" 137 | }, 138 | { 139 | "name": "approve", 140 | "inputs": [ 141 | { "name":"spender", "type":"address" }, 142 | { "name":"tokenId", "type":"uint128" } 143 | ], 144 | "outputs": [ 145 | ], 146 | "id": "0x18" 147 | }, 148 | { 149 | "name": "transferFrom", 150 | "inputs": [ 151 | { "name":"dest", "type":"address" }, 152 | { "name":"to", "type":"address" }, 153 | { "name":"tokenId", "type":"uint128" }, 154 | { "name":"grams", "type":"uint128" } 155 | ], 156 | "outputs": [ 157 | ], 158 | "id": "0x19" 159 | }, 160 | { 161 | "name": "internalTransferFrom", 162 | "inputs": [ 163 | { "name":"to", "type":"address" }, 164 | { "name":"tokenId", "type":"uint128" } 165 | ], 166 | "outputs": [ 167 | ], 168 | "id": "0x1a" 169 | }, 170 | { 171 | "name": "disapprove", 172 | "inputs": [ 173 | ], 174 | "outputs": [ 175 | ], 176 | "id": "0x1b" 177 | } 178 | ], 179 | "events": [ 180 | ] 181 | } 182 | -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/TONTokenWalletNF.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace tvm { namespace schema { 11 | 12 | using WalletGramsType = uint128; 13 | using TokensType = uint128; 14 | using TokenId = uint128; 15 | 16 | static constexpr unsigned TOKEN_WALLET_TIMESTAMP_DELAY = 100; 17 | using wallet_replay_protection_t = replay_attack_protection::timestamp; 18 | 19 | struct allowance_info { 20 | lazy spender; 21 | TokenId allowedToken; 22 | }; 23 | 24 | // ===== TON Token wallet ===== // 25 | __interface ITONTokenWallet { 26 | 27 | // expected offchain constructor execution 28 | __attribute__((internal, external, dyn_chain_parse)) 29 | void constructor(bytes name, bytes symbol, uint8 decimals, 30 | uint256 root_public_key, uint256 wallet_public_key, 31 | lazy root_address, cell code) = 11; 32 | 33 | __attribute__((external, noaccept, dyn_chain_parse)) 34 | void transfer(lazy dest, TokenId tokenId, WalletGramsType grams) = 12; 35 | 36 | // Receive tokens from root 37 | __attribute__((internal, noaccept)) 38 | void accept(TokenId tokenId) = 13; 39 | 40 | // Receive tokens from other wallet 41 | __attribute__((internal, noaccept)) 42 | void internalTransfer(TokenId tokenId, uint256 pubkey) = 14; 43 | 44 | // getters 45 | __attribute__((getter)) 46 | bytes getName() = 15; 47 | 48 | __attribute__((getter)) 49 | bytes getSymbol() = 16; 50 | 51 | __attribute__((getter)) 52 | uint8 getDecimals() = 17; 53 | 54 | __attribute__((getter)) 55 | TokensType getBalance() = 18; 56 | 57 | __attribute__((getter)) 58 | uint256 getWalletKey() = 19; 59 | 60 | __attribute__((getter)) 61 | lazy getRootAddress() = 20; 62 | 63 | __attribute__((getter)) 64 | allowance_info allowance() = 21; 65 | 66 | __attribute__((getter)) 67 | TokenId getTokenByIndex(TokensType index) = 22; 68 | 69 | __attribute__((getter)) 70 | lazy getApproved(TokenId tokenId) = 23; 71 | 72 | // allowance interface 73 | __attribute__((external, noaccept, dyn_chain_parse)) 74 | void approve(lazy spender, TokenId tokenId) = 24; 75 | 76 | __attribute__((external, noaccept, dyn_chain_parse)) 77 | void transferFrom(lazy dest, lazy to, TokenId tokenId, 78 | WalletGramsType grams) = 25; 79 | 80 | __attribute__((internal)) 81 | void internalTransferFrom(lazy to, TokenId tokenId) = 26; 82 | 83 | __attribute__((external, noaccept)) 84 | void disapprove() = 27; 85 | }; 86 | 87 | struct DTONTokenWallet { 88 | bytes name_; 89 | bytes symbol_; 90 | uint8 decimals_; 91 | uint256 root_public_key_; 92 | uint256 wallet_public_key_; 93 | lazy root_address_; 94 | cell code_; 95 | std::optional allowance_; 96 | dict_set tokens_; 97 | }; 98 | 99 | struct ETONTokenWallet { 100 | }; 101 | 102 | // Prepare Token Wallet StateInit structure and expected contract address (hash from StateInit) 103 | inline 104 | std::pair prepare_wallet_state_init_and_addr(DTONTokenWallet wallet_data) { 105 | cell wallet_data_cl = 106 | prepare_persistent_data( 107 | wallet_replay_protection_t::init(), wallet_data); 108 | StateInit wallet_init { 109 | /*split_depth*/{}, /*special*/{}, 110 | wallet_data.code_, wallet_data_cl, /*library*/{} 111 | }; 112 | cell wallet_init_cl = build(wallet_init).make_cell(); 113 | return { wallet_init, uint256(tvm_hash(wallet_init_cl)) }; 114 | } 115 | 116 | }} // namespace tvm::schema 117 | 118 | -------------------------------------------------------------------------------- /cpp/tokens-nonfungible/TONTokenWalletNF.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-nonfungible/TONTokenWalletNF.tvc -------------------------------------------------------------------------------- /cpp/tokens-utxo/RootTokenContractUTXO.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"decimals", "type":"uint8" }, 15 | { "name":"root_public_key", "type":"uint256" }, 16 | { "name":"wallet_code", "type":"cell" }, 17 | { "name":"total_supply", "type":"uint128" } 18 | ], 19 | "outputs": [ 20 | ], 21 | "id": "0xb" 22 | }, 23 | { 24 | "name": "deployWallet", 25 | "inputs": [ 26 | { "name":"workchain_id", "type":"int8" }, 27 | { "name":"pubkey", "type":"uint256" }, 28 | { "name":"tokens", "type":"uint128" }, 29 | { "name":"grams", "type":"uint128" } 30 | ], 31 | "outputs": [ 32 | { "name":"value0", "type":"address" } 33 | ], 34 | "id": "0xc" 35 | }, 36 | { 37 | "name": "mint", 38 | "inputs": [ 39 | { "name":"tokens", "type":"uint128" } 40 | ], 41 | "outputs": [ 42 | ], 43 | "id": "0xd" 44 | }, 45 | { 46 | "name": "getName", 47 | "inputs": [ 48 | ], 49 | "outputs": [ 50 | { "name":"value0", "type":"bytes" } 51 | ], 52 | "id": "0xe" 53 | }, 54 | { 55 | "name": "getSymbol", 56 | "inputs": [ 57 | ], 58 | "outputs": [ 59 | { "name":"value0", "type":"bytes" } 60 | ], 61 | "id": "0xf" 62 | }, 63 | { 64 | "name": "getDecimals", 65 | "inputs": [ 66 | ], 67 | "outputs": [ 68 | { "name":"value0", "type":"uint8" } 69 | ], 70 | "id": "0x10" 71 | }, 72 | { 73 | "name": "getRootKey", 74 | "inputs": [ 75 | ], 76 | "outputs": [ 77 | { "name":"value0", "type":"uint256" } 78 | ], 79 | "id": "0x11" 80 | }, 81 | { 82 | "name": "getTotalSupply", 83 | "inputs": [ 84 | ], 85 | "outputs": [ 86 | { "name":"value0", "type":"uint128" } 87 | ], 88 | "id": "0x12" 89 | }, 90 | { 91 | "name": "getTotalGranted", 92 | "inputs": [ 93 | ], 94 | "outputs": [ 95 | { "name":"value0", "type":"uint128" } 96 | ], 97 | "id": "0x13" 98 | }, 99 | { 100 | "name": "getWalletCode", 101 | "inputs": [ 102 | ], 103 | "outputs": [ 104 | { "name":"value0", "type":"cell" } 105 | ], 106 | "id": "0x14" 107 | }, 108 | { 109 | "name": "getWalletAddress", 110 | "inputs": [ 111 | { "name":"workchain_id", "type":"int8" }, 112 | { "name":"pubkey", "type":"uint256" } 113 | ], 114 | "outputs": [ 115 | { "name":"value0", "type":"address" } 116 | ], 117 | "id": "0x15" 118 | } 119 | ], 120 | "events": [ 121 | ] 122 | } 123 | -------------------------------------------------------------------------------- /cpp/tokens-utxo/RootTokenContractUTXO.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TONTokenWalletUTXO.hpp" 4 | 5 | namespace tvm { namespace schema { 6 | 7 | // ===== Root Token Contract ===== // 8 | __interface IRootTokenContract { 9 | 10 | // expected offchain constructor execution 11 | __attribute__((internal, external, dyn_chain_parse)) 12 | void constructor(bytes name, bytes symbol, uint8 decimals, 13 | uint256 root_public_key, cell wallet_code, TokensType total_supply) = 11; 14 | 15 | __attribute__((external, noaccept, dyn_chain_parse)) 16 | lazy deployWallet(int8 workchain_id, uint256 pubkey, TokensType tokens, WalletGramsType grams) = 12; 17 | 18 | __attribute__((external, noaccept, dyn_chain_parse)) 19 | void mint(TokensType tokens) = 13; 20 | 21 | __attribute__((getter)) 22 | bytes getName() = 14; 23 | 24 | __attribute__((getter)) 25 | bytes getSymbol() = 15; 26 | 27 | __attribute__((getter)) 28 | uint8 getDecimals() = 16; 29 | 30 | __attribute__((getter)) 31 | uint256 getRootKey() = 17; 32 | 33 | __attribute__((getter)) 34 | TokensType getTotalSupply() = 18; 35 | 36 | __attribute__((getter)) 37 | TokensType getTotalGranted() = 19; 38 | 39 | __attribute__((getter)) 40 | cell getWalletCode() = 20; 41 | 42 | __attribute__((getter)) 43 | lazy getWalletAddress(int8 workchain_id, uint256 pubkey) = 21; 44 | }; 45 | 46 | struct DRootTokenContract { 47 | bytes name_; 48 | bytes symbol_; 49 | uint8 decimals_; 50 | uint256 root_public_key_; 51 | TokensType total_supply_; 52 | TokensType total_granted_; 53 | cell wallet_code_; 54 | }; 55 | 56 | struct ERootTokenContract { 57 | }; 58 | 59 | }} // namespace tvm::schema 60 | 61 | -------------------------------------------------------------------------------- /cpp/tokens-utxo/RootTokenContractUTXO.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-utxo/RootTokenContractUTXO.tvc -------------------------------------------------------------------------------- /cpp/tokens-utxo/TONTokenWalletUTXO.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"name", "type":"bytes" }, 13 | { "name":"symbol", "type":"bytes" }, 14 | { "name":"decimals", "type":"uint8" }, 15 | { "name":"root_public_key", "type":"uint256" }, 16 | { "name":"wallet_public_key", "type":"uint256" }, 17 | { "name":"root_address", "type":"address" }, 18 | { "name":"code", "type":"cell" } 19 | ], 20 | "outputs": [ 21 | ], 22 | "id": "0xb" 23 | }, 24 | { 25 | "name": "transferUTXO", 26 | "inputs": [ 27 | { "name":"workchain_dest", "type":"int8" }, 28 | { "name":"pubkey_dest", "type":"uint256" }, 29 | { "name":"workchain_rest", "type":"int8" }, 30 | { "name":"pubkey_rest", "type":"uint256" }, 31 | { "name":"tokens", "type":"uint128" }, 32 | { "name":"grams_dest", "type":"uint128" } 33 | ], 34 | "outputs": [ 35 | ], 36 | "id": "0xc" 37 | }, 38 | { 39 | "name": "accept", 40 | "inputs": [ 41 | { "name":"tokens", "type":"uint128" } 42 | ], 43 | "outputs": [ 44 | ], 45 | "id": "0xd" 46 | }, 47 | { 48 | "name": "internalTransfer", 49 | "inputs": [ 50 | { "name":"tokens", "type":"uint128" }, 51 | { "name":"pubkey", "type":"uint256" } 52 | ], 53 | "outputs": [ 54 | ], 55 | "id": "0xe" 56 | }, 57 | { 58 | "name": "getName", 59 | "inputs": [ 60 | ], 61 | "outputs": [ 62 | { "name":"value0", "type":"bytes" } 63 | ], 64 | "id": "0xf" 65 | }, 66 | { 67 | "name": "getSymbol", 68 | "inputs": [ 69 | ], 70 | "outputs": [ 71 | { "name":"value0", "type":"bytes" } 72 | ], 73 | "id": "0x10" 74 | }, 75 | { 76 | "name": "getDecimals", 77 | "inputs": [ 78 | ], 79 | "outputs": [ 80 | { "name":"value0", "type":"uint8" } 81 | ], 82 | "id": "0x11" 83 | }, 84 | { 85 | "name": "getBalance", 86 | "inputs": [ 87 | ], 88 | "outputs": [ 89 | { "name":"value0", "type":"uint128" } 90 | ], 91 | "id": "0x12" 92 | }, 93 | { 94 | "name": "getWalletKey", 95 | "inputs": [ 96 | ], 97 | "outputs": [ 98 | { "name":"value0", "type":"uint256" } 99 | ], 100 | "id": "0x13" 101 | }, 102 | { 103 | "name": "getRootAddress", 104 | "inputs": [ 105 | ], 106 | "outputs": [ 107 | { "name":"value0", "type":"address" } 108 | ], 109 | "id": "0x14" 110 | } 111 | ], 112 | "events": [ 113 | ] 114 | } 115 | -------------------------------------------------------------------------------- /cpp/tokens-utxo/TONTokenWalletUTXO.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace tvm { namespace schema { 10 | 11 | using WalletGramsType = uint128; 12 | using TokensType = uint128; 13 | 14 | static constexpr unsigned TOKEN_WALLET_TIMESTAMP_DELAY = 100; 15 | using wallet_replay_protection_t = replay_attack_protection::timestamp; 16 | 17 | // ===== TON Token wallet ===== // 18 | __interface ITONTokenWallet { 19 | 20 | // expected offchain constructor execution 21 | __attribute__((internal, external, dyn_chain_parse)) 22 | void constructor(bytes name, bytes symbol, uint8 decimals, 23 | uint256 root_public_key, uint256 wallet_public_key, 24 | lazy root_address, cell code) = 11; 25 | 26 | // tokens and grams_dest will be sent to a new deployed {workchain_dest, pubkey_dest} wallet 27 | // and the rest of tokens and the rest of gas will be sent to new {workchain_rest, pubkey_rest} wallet 28 | __attribute__((external, noaccept, dyn_chain_parse)) 29 | void transferUTXO(int8 workchain_dest, uint256 pubkey_dest, int8 workchain_rest, uint256 pubkey_rest, 30 | TokensType tokens, WalletGramsType grams_dest) = 12; 31 | 32 | // TODO: eliminate workaround when bounced message problem will be solved 33 | // https://www.notion.so/tonlabs/Bounced-message-problem-333cf800e789421d87acd9cb401dca4f 34 | 35 | // Receive tokens from root 36 | __attribute__((internal, noaccept)) 37 | void accept(TokensType tokens) = 13; 38 | 39 | // Receive tokens from other wallet 40 | __attribute__((internal, noaccept)) 41 | void internalTransfer(TokensType tokens, uint256 pubkey) = 14; 42 | 43 | // getters 44 | __attribute__((getter)) 45 | bytes getName() = 15; 46 | 47 | __attribute__((getter)) 48 | bytes getSymbol() = 16; 49 | 50 | __attribute__((getter)) 51 | uint8 getDecimals() = 17; 52 | 53 | __attribute__((getter)) 54 | TokensType getBalance() = 18; 55 | 56 | __attribute__((getter)) 57 | uint256 getWalletKey() = 19; 58 | 59 | __attribute__((getter)) 60 | lazy getRootAddress() = 20; 61 | }; 62 | 63 | struct DTONTokenWallet { 64 | bool_t utxo_received_; 65 | bytes name_; 66 | bytes symbol_; 67 | uint8 decimals_; 68 | TokensType balance_; 69 | uint256 root_public_key_; 70 | uint256 wallet_public_key_; 71 | lazy root_address_; 72 | cell code_; 73 | }; 74 | 75 | struct ETONTokenWallet { 76 | }; 77 | 78 | // Prepare Token Wallet StateInit structure and expected contract address (hash from StateInit) 79 | inline 80 | std::pair prepare_wallet_state_init_and_addr(DTONTokenWallet wallet_data) { 81 | cell wallet_data_cl = 82 | prepare_persistent_data( 83 | wallet_replay_protection_t::init(), wallet_data); 84 | StateInit wallet_init { 85 | /*split_depth*/{}, /*special*/{}, 86 | wallet_data.code_, wallet_data_cl, /*library*/{} 87 | }; 88 | cell wallet_init_cl = build(wallet_init).make_cell(); 89 | return { wallet_init, uint256(tvm_hash(wallet_init_cl)) }; 90 | } 91 | 92 | }} // namespace tvm::schema 93 | 94 | -------------------------------------------------------------------------------- /cpp/tokens-utxo/TONTokenWalletUTXO.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/cpp/tokens-utxo/TONTokenWalletUTXO.tvc -------------------------------------------------------------------------------- /debots/AddressInput.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >=0.35.0; 2 | 3 | interface IAddressInput { 4 | function select(uint32 answerId) external returns (address value); 5 | } 6 | 7 | library AddressInput { 8 | int8 constant DEBOT_WC = -31; 9 | uint256 constant ID = 0xd7ed1bd8e6230871116f4522e58df0a93c5520c56f4ade23ef3d8919a984653b; 10 | 11 | function select(uint32 answerId) public pure { 12 | address addr = address.makeAddrStd(DEBOT_WC, ID); 13 | IAddressInput(addr).select(answerId); 14 | } 15 | } 16 | 17 | contract AddressInputABI is IAddressInput { 18 | function select(uint32 answerId) external override returns (address value) {} 19 | } -------------------------------------------------------------------------------- /debots/Menu.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >=0.35.0; 2 | 3 | struct MenuItem { 4 | string title; 5 | string description; 6 | uint32 handlerId; 7 | } 8 | 9 | interface IMenu { 10 | 11 | function select(string title, string description, MenuItem[] items) external returns (uint32 index); 12 | 13 | } 14 | 15 | library Menu { 16 | 17 | uint256 constant ID = 0xac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function select(string title, string description, MenuItem[] items) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | IMenu(addr).select(title, description, items); 23 | } 24 | } 25 | 26 | contract MenuABI is IMenu { 27 | 28 | function select(string title, string description, MenuItem[] items) external override returns (uint32 index) {} 29 | 30 | } -------------------------------------------------------------------------------- /debots/Sdk.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >=0.35.0; 2 | interface ISdk { 3 | //account info 4 | function getBalance(uint32 answerId, address addr) external returns (uint128 nanotokens); 5 | function getAccountType(uint32 answerId, address addr) external returns (int8 acc_type); 6 | function getAccountCodeHash(uint32 answerId, address addr) external returns (uint256 code_hash); 7 | //crypto 8 | function chacha20(uint32 answerId, bytes data, bytes nonce, uint256 key) external returns (bytes output); 9 | //crypto utils 10 | function signHash(uint32 answerId, uint256 hash) external returns (bytes arg1); 11 | function genRandom(uint32 answerId, uint32 length) external returns (bytes buffer); 12 | //7z 13 | function compress7z(uint32 answerId, bytes uncompressed) external returns (bytes comp); 14 | function uncompress7z(uint32 answerId, bytes compressed) external returns (bytes uncomp); 15 | } 16 | 17 | 18 | 19 | library Sdk { 20 | 21 | uint256 constant ITF_ADDR = 0x8fc6454f90072c9f1f6d3313ae1608f64f4a0660c6ae9f42c68b6a79e2a1bc4b; 22 | int8 constant DEBOT_WC = -31; 23 | 24 | function getBalance(uint32 answerId, address addr) public pure { 25 | address a = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 26 | ISdk(a).getBalance(answerId, addr); 27 | } 28 | function getAccountType(uint32 answerId, address addr) public pure { 29 | address a = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 30 | ISdk(a).getAccountType(answerId, addr); 31 | } 32 | function getAccountCodeHash(uint32 answerId, address addr) public pure { 33 | address a = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 34 | ISdk(a).getAccountCodeHash(answerId, addr); 35 | } 36 | 37 | function chacha20(uint32 answerId, bytes data, bytes nonce, uint256 key) public pure { 38 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 39 | ISdk(addr).chacha20(answerId, data, nonce, key); 40 | } 41 | 42 | function signHash(uint32 answerId, uint256 hash) public pure { 43 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 44 | ISdk(addr).signHash(answerId, hash); 45 | } 46 | function genRandom(uint32 answerId, uint32 length) public pure { 47 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 48 | ISdk(addr).genRandom(answerId, length); 49 | } 50 | 51 | function compress7z(uint32 answerId, bytes uncompressed) public pure { 52 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 53 | ISdk(addr).compress7z(answerId, uncompressed); 54 | } 55 | function uncompress7z(uint32 answerId, bytes compressed) public pure { 56 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 57 | ISdk(addr).uncompress7z(answerId, compressed); 58 | } 59 | 60 | } 61 | 62 | contract SdkABI is ISdk { 63 | //account info 64 | function getBalance(uint32 answerId, address addr) external override returns (uint128 nanotokens) {} 65 | function getAccountType(uint32 answerId, address addr) external override returns (int8 acc_type) {} 66 | function getAccountCodeHash(uint32 answerId, address addr) external override returns (uint256 code_hash) {} 67 | //crypto 68 | function chacha20(uint32 answerId, bytes data, bytes nonce, uint256 key) external override returns (bytes output) {} 69 | //crypto utils 70 | function signHash(uint32 answerId, uint256 hash) external override returns (bytes arg1) {} 71 | function genRandom(uint32 answerId, uint32 length) external override returns (bytes buffer) {} 72 | //7z 73 | function compress7z(uint32 answerId, bytes uncompressed) external override returns (bytes comp) {} 74 | function uncompress7z(uint32 answerId, bytes compressed) external override returns (bytes uncomp) {} 75 | } -------------------------------------------------------------------------------- /debots/Terminal.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >=0.35.0; 2 | 3 | interface ITerminal { 4 | 5 | function inputStr(uint32 answerId, string prompt, bool multiline) external returns (string value); 6 | function inputInt (uint32 answerId, string prompt) external returns (int256 value); 7 | function inputUint(uint32 answerId, string prompt) external returns (uint256 value); 8 | function inputTons(uint32 answerId, string prompt) external returns (uint128 value); 9 | function inputBoolean(uint32 answerId, string prompt) external returns (bool value); 10 | function print(uint32 answerId, string message) external; 11 | function printf(uint32 answerId, string fmt, TvmCell fargs) external; 12 | 13 | } 14 | 15 | library Terminal { 16 | 17 | uint256 constant ID = 0x8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function inputStr(uint32 answerId, string prompt, bool multiline) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | ITerminal(addr).inputStr(answerId, prompt, multiline); 23 | } 24 | function inputInt(uint32 answerId, string prompt) public pure { 25 | address addr = address.makeAddrStd(DEBOT_WC, ID); 26 | ITerminal(addr).inputInt(answerId, prompt); 27 | } 28 | function inputUint(uint32 answerId, string prompt) public pure { 29 | address addr = address.makeAddrStd(DEBOT_WC, ID); 30 | ITerminal(addr).inputUint(answerId, prompt); 31 | } 32 | function inputTons(uint32 answerId, string prompt) public pure { 33 | address addr = address.makeAddrStd(DEBOT_WC, ID); 34 | ITerminal(addr).inputTons(answerId, prompt); 35 | } 36 | function inputBoolean(uint32 answerId, string prompt) public pure { 37 | address addr = address.makeAddrStd(DEBOT_WC, ID); 38 | ITerminal(addr).inputBoolean(answerId, prompt); 39 | } 40 | function print(uint32 answerId, string message) public pure { 41 | address addr = address.makeAddrStd(DEBOT_WC, ID); 42 | ITerminal(addr).print(answerId, message); 43 | } 44 | function printf(uint32 answerId, string fmt, TvmCell fargs) public pure { 45 | address addr = address.makeAddrStd(DEBOT_WC, ID); 46 | ITerminal(addr).printf(answerId, fmt, fargs); 47 | } 48 | } 49 | 50 | contract TerminalABI is ITerminal { 51 | 52 | function inputStr(uint32 answerId, string prompt, bool multiline) external override returns (string value) {} 53 | function inputInt (uint32 answerId, string prompt) external override returns (int256 value) {} 54 | function inputUint(uint32 answerId, string prompt) external override returns (uint256 value) {} 55 | function inputTons(uint32 answerId, string prompt) external override returns (uint128 value) {} 56 | function inputBoolean(uint32 answerId, string prompt) external override returns (bool value) {} 57 | function print(uint32 answerId, string message) external override {} 58 | function printf(uint32 answerId, string fmt, TvmCell fargs) external override {} 59 | 60 | } -------------------------------------------------------------------------------- /debots/msig/msigDebot2.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"debotAbi","type":"bytes"} 9 | ], 10 | "outputs": [ 11 | ] 12 | }, 13 | { 14 | "name": "start", 15 | "inputs": [ 16 | ], 17 | "outputs": [ 18 | ] 19 | }, 20 | { 21 | "name": "getVersion", 22 | "inputs": [ 23 | ], 24 | "outputs": [ 25 | {"name":"name","type":"bytes"}, 26 | {"name":"semver","type":"uint24"} 27 | ] 28 | }, 29 | { 30 | "name": "selectWallet", 31 | "inputs": [ 32 | {"name":"index","type":"uint32"} 33 | ], 34 | "outputs": [ 35 | ] 36 | }, 37 | { 38 | "name": "checkWallet", 39 | "inputs": [ 40 | {"name":"value","type":"address"} 41 | ], 42 | "outputs": [ 43 | ] 44 | }, 45 | { 46 | "name": "setBalance", 47 | "inputs": [ 48 | {"name":"nanotokens","type":"uint128"} 49 | ], 50 | "outputs": [ 51 | ] 52 | }, 53 | { 54 | "name": "getWalletInfo", 55 | "inputs": [ 56 | {"name":"acc_type","type":"int8"} 57 | ], 58 | "outputs": [ 59 | ] 60 | }, 61 | { 62 | "name": "queryCustodians", 63 | "inputs": [ 64 | ], 65 | "outputs": [ 66 | ] 67 | }, 68 | { 69 | "name": "setCustodians", 70 | "inputs": [ 71 | {"components":[{"name":"index","type":"uint8"},{"name":"pubkey","type":"uint256"}],"name":"custodians","type":"tuple[]"} 72 | ], 73 | "outputs": [ 74 | ] 75 | }, 76 | { 77 | "name": "setTons", 78 | "inputs": [ 79 | {"name":"value","type":"uint128"} 80 | ], 81 | "outputs": [ 82 | ] 83 | }, 84 | { 85 | "name": "setDest", 86 | "inputs": [ 87 | {"name":"value","type":"address"} 88 | ], 89 | "outputs": [ 90 | ] 91 | }, 92 | { 93 | "name": "setBounce", 94 | "inputs": [ 95 | {"name":"value","type":"bool"} 96 | ], 97 | "outputs": [ 98 | ] 99 | }, 100 | { 101 | "name": "submit", 102 | "inputs": [ 103 | {"name":"value","type":"bool"} 104 | ], 105 | "outputs": [ 106 | ] 107 | }, 108 | { 109 | "name": "setResult", 110 | "inputs": [ 111 | ], 112 | "outputs": [ 113 | ] 114 | }, 115 | { 116 | "name": "upgrade", 117 | "inputs": [ 118 | {"name":"state","type":"cell"} 119 | ], 120 | "outputs": [ 121 | ] 122 | }, 123 | { 124 | "name": "fetch", 125 | "inputs": [ 126 | ], 127 | "outputs": [ 128 | {"components":[{"name":"id","type":"uint8"},{"name":"desc","type":"bytes"},{"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"actions","type":"tuple[]"}],"name":"contexts","type":"tuple[]"} 129 | ] 130 | }, 131 | { 132 | "name": "getDebotOptions", 133 | "inputs": [ 134 | ], 135 | "outputs": [ 136 | {"name":"options","type":"uint8"}, 137 | {"name":"debotAbi","type":"bytes"}, 138 | {"name":"targetAbi","type":"bytes"}, 139 | {"name":"targetAddr","type":"address"} 140 | ] 141 | } 142 | ], 143 | "data": [ 144 | ], 145 | "events": [ 146 | ] 147 | } 148 | -------------------------------------------------------------------------------- /debots/msig/msigDebot2.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/debots/msig/msigDebot2.tvc -------------------------------------------------------------------------------- /dens/redens/README.md: -------------------------------------------------------------------------------- 1 | # How to create DeBot derived from your smart contract 2 | 3 | Important note: use soc version >= 0.40.0 to compile your DeBot sol file. 4 | This will guarantee you a successful update of ReDeNS smart contract to real DeBot. 5 | ## Prepare initial ReDeNS files 6 | 7 | You need redens.tvc, redens.abi.json, debots.key.json. 8 | 9 | Also you need `tonos-cli` >= 0.11.0 version. 10 | 11 | ## Generate author seed phrase 12 | 13 | tonos-cli genphrase 14 | 15 | Important: dont forget or loose the phrase. It is needed to upgrade ReDeNS to real DeBot. 16 | 17 | ## Get author public key 18 | 19 | tonos-cli genpubkey "author seed phrase" 20 | 21 | `author seed phrase` - the seed phrase generated at previous step. 22 | 23 | ## Prepare ReDeNS Image 24 | 25 | Copy and rename the original ReDeNS image: 26 | 27 | cp redens.tvc redens.tvc 28 | 29 | `DebotName` - name of you DeBot. Example: 30 | 31 | cp redens.tvc redensDePool.tvc 32 | 33 | Generate ReDeNS address and update image file: 34 | 35 | tonos-cli genaddr redens.tvc redens.abi.json --setkey debots.key.json --data '{"codeHash":""}' --wc 0 --save 36 | 37 | `codeHashOfYourSmartContract` - insert here code hash of your smart contract starting with `0x`. 38 | 39 | redens.tvc file will be rewritten. 40 | 41 | Remember `Raw address` printed to the terminal. It is the address of your DeBot. 42 | 43 | ## Deploy ReDeNS to blockchain 44 | 45 | Send 2 tons to the address generated at previous step. 46 | 47 | Deploy image using cli: 48 | 49 | tonos-cli deploy redens.tvc '{"pubkey":""}' --abi redens.abi.json --sign "author seed phrase" 50 | 51 | `authorPublicKey` - insert here the author public key starting with `0x`. 52 | 53 | ## Upgrade ReDeNS to real DeBot 54 | 55 | Run `update.sh` script: 56 | 57 | update.sh
58 | 59 | `address` - Free TON address of Reverse DeBot Certificate. 60 | 61 | `DeBotFileName` - the name of DeBot used as prefix for tvc and abi.json files. For example, if name is `msigDebot` then script will try to read `msigDebot.tvc` and `msigDebot.abi.json` files. 62 | 63 | -------------------------------------------------------------------------------- /dens/redens/debots.key.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "a7dd1ac8f6915ec1bf0d0e72686129b24abb902cd6dc28ed7148f5d9360d32d8", 3 | "secret": "0000000000000000000000000000000000000000000000000000000000000000" 4 | } -------------------------------------------------------------------------------- /dens/redens/redens.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"pubkey","type":"uint256"} 9 | ], 10 | "outputs": [ 11 | ] 12 | }, 13 | { 14 | "name": "getAuthorKey", 15 | "inputs": [ 16 | ], 17 | "outputs": [ 18 | {"name":"authorKey","type":"uint256"} 19 | ] 20 | }, 21 | { 22 | "name": "upgrade", 23 | "inputs": [ 24 | {"name":"state","type":"cell"} 25 | ], 26 | "outputs": [ 27 | ] 28 | }, 29 | { 30 | "name": "codeHash", 31 | "inputs": [ 32 | ], 33 | "outputs": [ 34 | {"name":"codeHash","type":"uint256"} 35 | ] 36 | } 37 | ], 38 | "data": [ 39 | {"key":1,"name":"codeHash","type":"uint256"} 40 | ], 41 | "events": [ 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /dens/redens/redens.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity >=0.40.0; 2 | pragma AbiHeader expire; 3 | pragma AbiHeader time; 4 | pragma AbiHeader pubkey; 5 | import "../Upgradable.sol"; 6 | 7 | contract Redens is Upgradable { 8 | uint256 static public codeHash; 9 | 10 | constructor(uint256 pubkey) public { 11 | require(msg.pubkey() == pubkey, 100); 12 | tvm.accept(); 13 | tvm.setPubkey(pubkey); 14 | } 15 | 16 | function getAuthorKey() public view returns (uint256 authorKey) { 17 | authorKey = tvm.pubkey(); 18 | } 19 | 20 | function onCodeUpgrade() internal override { 21 | tvm.resetStorage(); 22 | } 23 | } -------------------------------------------------------------------------------- /dens/redens/redens.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/dens/redens/redens.tvc -------------------------------------------------------------------------------- /dens/redens/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | tos=./tonos-cli 4 | if test -f "$tos"; then 5 | echo "$tos exists." 6 | else 7 | echo "$tos not found in current directory. Please, copy it here and rerun script." 8 | exit 9 | fi 10 | 11 | debot=$1 12 | debot_name=$2 13 | debot_abi=$(cat $debot_name.abi.json | xxd -ps -c 20000) 14 | new_state=$( base64 -w 0 $debot_name.tvc) 15 | signer=$3 16 | 17 | echo "{\"state\":\"$new_state\"}" > upgrade.txt 18 | $tos call $debot upgrade upgrade.txt --sign "$signer" --abi $debot_name.abi.json 19 | $tos call $debot setABI "{\"dabi\":\"$debot_abi\"}" --sign "$signer" --abi $debot_name.abi.json 20 | rm upgrade.txt 21 | echo DONE -------------------------------------------------------------------------------- /governance/SMV/Budget.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "time", 5 | "expire" 6 | ], 7 | "functions": [ 8 | { 9 | "name": "constructor", 10 | "inputs": [ 11 | { "name":"SMV_root", "type":"address" } 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "request", 18 | "inputs": [ 19 | { "name":"proposalId", "type":"uint256" }, 20 | { "name":"contestAddr", "type":"address" }, 21 | { "name":"requestValue", "type":"uint256" } 22 | ], 23 | "outputs": [ 24 | ] 25 | } 26 | ], 27 | "events": [ 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /governance/SMV/Budget.cpp: -------------------------------------------------------------------------------- 1 | #include "Budget.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace tvm; 10 | using namespace schema; 11 | 12 | static constexpr unsigned TIMESTAMP_DELAY = 1800; 13 | 14 | class Budget final : public smart_interface, public DBudget { 15 | public: 16 | using replay_protection_t = replay_attack_protection::timestamp; 17 | 18 | struct error_code : tvm::error_code { 19 | static constexpr unsigned wrong_sender_address = 100; 20 | }; 21 | 22 | __always_inline 23 | void constructor(address SMV_root) { 24 | SMV_root_ = SMV_root; 25 | } 26 | 27 | __always_inline 28 | void request(uint256 proposalId, address contestAddr, uint256 requestValue) { 29 | require(int_sender() == SMV_root_, error_code::wrong_sender_address); 30 | 31 | tvm_transfer(contestAddr, requestValue.get(), /*bounce*/true); 32 | } 33 | 34 | // ==================== Support methods =========================== // 35 | 36 | // default processing of unknown messages 37 | __always_inline static int _fallback(cell msg, slice msg_body) { 38 | return 0; 39 | } 40 | DEFAULT_SUPPORT_FUNCTIONS(IBudget, replay_protection_t); 41 | }; 42 | 43 | DEFINE_JSON_ABI(IBudget, DBudget, EBudget); 44 | 45 | // ----------------------------- Main entry functions ---------------------- // 46 | DEFAULT_MAIN_ENTRY_FUNCTIONS(Budget, IBudget, DBudget, TIMESTAMP_DELAY) 47 | 48 | -------------------------------------------------------------------------------- /governance/SMV/Budget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace tvm { namespace schema { 6 | 7 | __interface [[no_pubkey]] IBudget { 8 | 9 | [[internal, external, dyn_chain_parse]] 10 | void constructor(address SMV_root); 11 | 12 | [[internal, noaccept]] 13 | void request(uint256 proposalId, address contestAddr, uint256 requestValue); 14 | }; 15 | 16 | struct DBudget { 17 | address SMV_root_; 18 | }; 19 | 20 | struct EBudget {}; 21 | 22 | }} // namespace tvm::schema 23 | 24 | -------------------------------------------------------------------------------- /governance/SMV/Budget.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/Budget.tvc -------------------------------------------------------------------------------- /governance/SMV/Contest.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "time", 5 | "expire" 6 | ], 7 | "functions": [ 8 | { 9 | "name": "constructor", 10 | "inputs": [ 11 | { "name":"title", "type":"bytes" }, 12 | { "name":"link", "type":"bytes" }, 13 | { "name":"hash", "type":"uint256" }, 14 | { "name":"juryAddr", "type":"address" }, 15 | { "name":"juryKeys", "type":"uint256[]" }, 16 | { "name":"startsIn", "type":"uint64" }, 17 | { "name":"lastsFor", "type":"uint64" }, 18 | { "name":"votingWindow", "type":"uint64" }, 19 | { "name":"sendApprovalGrams", "type":"uint256" } 20 | ], 21 | "outputs": [ 22 | ], 23 | "id": "0x309" 24 | }, 25 | { 26 | "name": "sendApproval", 27 | "inputs": [ 28 | ], 29 | "outputs": [ 30 | ] 31 | }, 32 | { 33 | "name": "getTitle", 34 | "inputs": [ 35 | ], 36 | "outputs": [ 37 | { "name":"value0", "type":"bytes" } 38 | ] 39 | }, 40 | { 41 | "name": "getLink", 42 | "inputs": [ 43 | ], 44 | "outputs": [ 45 | { "name":"value0", "type":"bytes" } 46 | ] 47 | }, 48 | { 49 | "name": "getHash", 50 | "inputs": [ 51 | ], 52 | "outputs": [ 53 | { "name":"value0", "type":"uint256" } 54 | ] 55 | }, 56 | { 57 | "name": "getJuryAddr", 58 | "inputs": [ 59 | ], 60 | "outputs": [ 61 | { "name":"value0", "type":"address" } 62 | ] 63 | }, 64 | { 65 | "name": "getJuryKeys", 66 | "inputs": [ 67 | ], 68 | "outputs": [ 69 | { "name":"value0", "type":"uint256[]" } 70 | ] 71 | }, 72 | { 73 | "name": "getStartsIn", 74 | "inputs": [ 75 | ], 76 | "outputs": [ 77 | { "name":"value0", "type":"uint64" } 78 | ] 79 | }, 80 | { 81 | "name": "getLastsFor", 82 | "inputs": [ 83 | ], 84 | "outputs": [ 85 | { "name":"value0", "type":"uint64" } 86 | ] 87 | }, 88 | { 89 | "name": "getVotingWindow", 90 | "inputs": [ 91 | ], 92 | "outputs": [ 93 | { "name":"value0", "type":"uint64" } 94 | ] 95 | } 96 | ], 97 | "events": [ 98 | ] 99 | } 100 | -------------------------------------------------------------------------------- /governance/SMV/Contest.cpp: -------------------------------------------------------------------------------- 1 | #include "ProposalRoot.hpp" 2 | #include "MultiBallot.hpp" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace tvm; 11 | using namespace schema; 12 | 13 | static constexpr unsigned TIMESTAMP_DELAY = 1800; 14 | using replay_protection_t = replay_attack_protection::timestamp; 15 | 16 | __interface [[no_pubkey]] ITestContest { 17 | [[internal, noaccept, dyn_chain_parse]] 18 | void constructor(bytes title, bytes link, uint256 hash, address juryAddr, 19 | dict_array juryKeys, uint64 startsIn, uint64 lastsFor, uint64 votingWindow, 20 | uint256 sendApprovalGrams) = 777; 21 | 22 | [[internal, noaccept]] 23 | void sendApproval(); 24 | 25 | // ============== getters ============== 26 | [[getter]] 27 | bytes getTitle(); 28 | 29 | [[getter]] 30 | bytes getLink(); 31 | 32 | [[getter]] 33 | uint256 getHash(); 34 | 35 | [[getter]] 36 | address getJuryAddr(); 37 | 38 | [[getter]] 39 | dict_array getJuryKeys(); 40 | 41 | [[getter]] 42 | uint64 getStartsIn(); 43 | 44 | [[getter]] 45 | uint64 getLastsFor(); 46 | 47 | [[getter]] 48 | uint64 getVotingWindow(); 49 | }; 50 | 51 | struct DTestContest { 52 | bytes title_; 53 | bytes link_; 54 | uint256 hash_; 55 | address juryAddr_; 56 | dict_array juryKeys_; 57 | uint64 startsIn_; 58 | uint64 lastsFor_; 59 | uint64 votingWindow_; 60 | handle proposal_; 61 | Grams sendApprovalGrams_; 62 | }; 63 | 64 | __interface ETestContest { 65 | }; 66 | 67 | class TestContest final : public smart_interface, public DTestContest { 68 | public: 69 | __always_inline 70 | void constructor(bytes title, bytes link, uint256 hash, address juryAddr, 71 | dict_array juryKeys, uint64 startsIn, uint64 lastsFor, uint64 votingWindow, 72 | uint256 sendApprovalGrams) { 73 | title_ = title; 74 | link_ = link; 75 | hash_ = hash; 76 | juryAddr_ = juryAddr; 77 | juryKeys_ = juryKeys; 78 | startsIn_ = startsIn; 79 | lastsFor_ = lastsFor; 80 | votingWindow_ = votingWindow; 81 | proposal_ = handle{ int_sender() }; 82 | sendApprovalGrams_ = sendApprovalGrams.get(); 83 | } 84 | 85 | __always_inline 86 | void sendApproval() { 87 | proposal_(sendApprovalGrams_).contestApproved(); 88 | } 89 | 90 | // ========== getters ========== 91 | __always_inline 92 | bytes getTitle() { 93 | return title_; 94 | } 95 | __always_inline 96 | bytes getLink() { 97 | return link_; 98 | } 99 | __always_inline 100 | uint256 getHash() { 101 | return hash_; 102 | } 103 | __always_inline 104 | address getJuryAddr() { 105 | return juryAddr_; 106 | } 107 | __always_inline 108 | dict_array getJuryKeys() { 109 | return juryKeys_; 110 | } 111 | __always_inline 112 | uint64 getStartsIn() { 113 | return startsIn_; 114 | } 115 | __always_inline 116 | uint64 getLastsFor() { 117 | return lastsFor_; 118 | } 119 | __always_inline 120 | uint64 getVotingWindow() { 121 | return votingWindow_; 122 | } 123 | public: 124 | // ==================== Support methods =========================== // 125 | // default processing of unknown messages 126 | __always_inline static int _fallback(cell msg, slice msg_body) { 127 | return 0; 128 | } 129 | DEFAULT_SUPPORT_FUNCTIONS(ITestContest, replay_protection_t); 130 | }; 131 | 132 | DEFINE_JSON_ABI(ITestContest, DTestContest, ETestContest); 133 | 134 | // ----------------------------- Main entry functions ---------------------- // 135 | DEFAULT_MAIN_ENTRY_FUNCTIONS(TestContest, ITestContest, DTestContest, TIMESTAMP_DELAY) 136 | 137 | -------------------------------------------------------------------------------- /governance/SMV/Contest.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/Contest.tvc -------------------------------------------------------------------------------- /governance/SMV/DePool.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace tvm { namespace schema { 6 | 7 | __interface IDePool { 8 | __attribute__((internal, noaccept)) 9 | void transferStake(address destination, uint64 amount) = 0x6810bf4e; // = hash_v<"transferStake(address,uint64)()v2"> 10 | }; 11 | 12 | using IDePoolPtr = contract_handle; 13 | 14 | }} // namespace tvm::schema 15 | 16 | -------------------------------------------------------------------------------- /governance/SMV/Makefile: -------------------------------------------------------------------------------- 1 | all: Budget.tvc MultiBallot.tvc ProposalRoot.tvc SuperRoot.tvc SMVStats.tvc TestSMVStats.tvc Contest.tvc 2 | 3 | Budget.tvc: Budget.cpp Budget.hpp config.hpp 4 | clang -o Budget.tvc Budget.cpp 5 | 6 | MultiBallot.tvc: MultiBallot.cpp MultiBallot.hpp DePool.hpp ProposalRoot.hpp config.hpp 7 | clang -o MultiBallot.tvc MultiBallot.cpp 8 | 9 | ProposalRoot.tvc: ProposalRoot.cpp MultiBallot.hpp DePool.hpp ProposalRoot.hpp SuperRoot.hpp Budget.hpp config.hpp 10 | clang -o ProposalRoot.tvc ProposalRoot.cpp 11 | 12 | SuperRoot.tvc: SuperRoot.cpp MultiBallot.hpp DePool.hpp ProposalRoot.hpp SuperRoot.hpp Budget.hpp config.hpp 13 | clang -o SuperRoot.tvc SuperRoot.cpp 14 | 15 | SMVStats.tvc: SMVStats.cpp SMVStats.hpp config.hpp 16 | clang -o SMVStats.tvc SMVStats.cpp 17 | 18 | Contest.tvc: Contest.cpp ProposalRoot.hpp MultiBallot.hpp config.hpp 19 | clang -o Contest.tvc Contest.cpp 20 | 21 | -------------------------------------------------------------------------------- /governance/SMV/MultiBallot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "deployBallot", 11 | "inputs": [ 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "receiveNativeTransfer", 18 | "inputs": [ 19 | { "name":"amount", "type":"uint256" } 20 | ], 21 | "outputs": [ 22 | ] 23 | }, 24 | { 25 | "name": "receiveStakeTransfer", 26 | "inputs": [ 27 | { "name":"source", "type":"address" }, 28 | { "name":"amount", "type":"uint128" } 29 | ], 30 | "outputs": [ 31 | ], 32 | "id": "0x23c4771d" 33 | }, 34 | { 35 | "name": "sendVote", 36 | "inputs": [ 37 | { "name":"proposal", "type":"address" }, 38 | { "name":"yesOrNo", "type":"bool" } 39 | ], 40 | "outputs": [ 41 | { "name":"has_deposit", "type":"uint256" }, 42 | { "name":"already_sent_deposit", "type":"uint256" }, 43 | { "name":"new_sent_deposit", "type":"uint256" } 44 | ] 45 | }, 46 | { 47 | "name": "requestDeposit", 48 | "inputs": [ 49 | { "name":"user_wallet", "type":"address" } 50 | ], 51 | "outputs": [ 52 | ] 53 | }, 54 | { 55 | "name": "finalize", 56 | "inputs": [ 57 | { "name":"user_wallet", "type":"address" } 58 | ], 59 | "outputs": [ 60 | ] 61 | }, 62 | { 63 | "name": "getDepool", 64 | "inputs": [ 65 | ], 66 | "outputs": [ 67 | { "name":"value0", "type":"address" } 68 | ] 69 | }, 70 | { 71 | "name": "getNativeDeposit", 72 | "inputs": [ 73 | ], 74 | "outputs": [ 75 | { "name":"value0", "type":"uint256" } 76 | ] 77 | }, 78 | { 79 | "name": "getStakeDeposit", 80 | "inputs": [ 81 | ], 82 | "outputs": [ 83 | { "name":"value0", "type":"uint256" } 84 | ] 85 | }, 86 | { 87 | "name": "getMultiBallot_receiveNativeTransfer_GasPrice", 88 | "inputs": [ 89 | ], 90 | "outputs": [ 91 | { "name":"value0", "type":"uint256" } 92 | ] 93 | }, 94 | { 95 | "name": "getMultiBallot_receiveStakeTransfer_GasPrice", 96 | "inputs": [ 97 | ], 98 | "outputs": [ 99 | { "name":"value0", "type":"uint256" } 100 | ] 101 | } 102 | ], 103 | "events": [ 104 | ] 105 | } 106 | -------------------------------------------------------------------------------- /governance/SMV/MultiBallot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace tvm { namespace schema { 11 | 12 | using VotesType = uint128; 13 | using DepositType = uint256; 14 | 15 | #define GASTOGRAM_WORKAROUND 16 | 17 | __always_inline unsigned gastogram(unsigned gas) { 18 | // TODO: solve gastogram problem 19 | #ifdef GASTOGRAM_WORKAROUND 20 | return gas * 10000; 21 | #else 22 | return __builtin_tvm_gastogram(gas); 23 | #endif 24 | } 25 | 26 | static constexpr unsigned MULTI_BALLOT_TIMESTAMP_DELAY = 1800; 27 | using multi_ballot_replay_protection_t = replay_attack_protection::timestamp; 28 | 29 | struct sendVotesResult { 30 | DepositType has_deposit; 31 | DepositType already_sent_deposit; 32 | DepositType new_sent_deposit; 33 | }; 34 | 35 | struct requestDepositResult { 36 | bool_t succeeded; 37 | uint256 unfinished_proposal; 38 | }; 39 | 40 | __interface IMultiBallot { 41 | 42 | // Initializes ballot variables 43 | [[internal, noaccept]] 44 | void deployBallot(); 45 | 46 | // Receive native funds transfer and keep it in deposit 47 | [[internal, noaccept]] 48 | void receiveNativeTransfer(DepositType amount); 49 | 50 | // Receive stake transfer notify (from solidity IParticipant::onTransfer(address source, uint128 amount)) 51 | [[internal, noaccept]] 52 | void receiveStakeTransfer(address source, uint128 amount) = 0x23c4771d; // = hash_v<"onTransfer(address,uint128)()v2"> 53 | 54 | // ======= externals ======= 55 | 56 | // Sends all votes (for deposit) to Proposal Root contract 57 | [[external, noaccept, dyn_chain_parse]] 58 | sendVotesResult sendVote(address proposal, bool_t yesOrNo); 59 | 60 | // The function must request affected proposals the voting is finished, 61 | // set to zero deposit variables and return stake and native deposits to user_wallet 62 | [[external, noaccept, dyn_chain_parse]] 63 | resumable requestDeposit(address user_wallet); 64 | 65 | // send all remaining tons to user_wallet 66 | [[external, noaccept, dyn_chain_parse]] 67 | void finalize(address user_wallet); 68 | 69 | // ======= getters ======= 70 | 71 | [[getter]] 72 | address getDepool(); 73 | 74 | [[getter]] 75 | DepositType getNativeDeposit(); 76 | 77 | [[getter]] 78 | DepositType getStakeDeposit(); 79 | 80 | [[getter, no_persistent]] 81 | DepositType getMultiBallot_receiveNativeTransfer_GasPrice(); 82 | 83 | [[getter, no_persistent]] 84 | DepositType getMultiBallot_receiveStakeTransfer_GasPrice(); 85 | }; 86 | 87 | struct DMultiBallot { 88 | uint256 ballot_public_key_; 89 | int8 workchain_id_; 90 | uint256 super_root_; 91 | address depool_; 92 | DepositType native_deposit_; 93 | DepositType stake_deposit_; 94 | 95 | // map of voted proposal addresses to sent deposit 96 | dict_map proposals_; 97 | }; 98 | 99 | struct EMultiBallot { 100 | }; 101 | 102 | // Prepare MultiBallot StateInit structure and expected contract address (hash from StateInit) 103 | inline 104 | std::pair prepare_ballot_state_init_and_addr(DMultiBallot ballot_data, cell ballot_code) { 105 | cell ballot_data_cl = 106 | prepare_persistent_data( 107 | { multi_ballot_replay_protection_t::init(), {} }, ballot_data); 108 | StateInit ballot_init { 109 | /*split_depth*/{}, /*special*/{}, 110 | ballot_code, ballot_data_cl, /*library*/{} 111 | }; 112 | cell ballot_init_cl = build(ballot_init).make_cell(); 113 | return { ballot_init, uint256(tvm_hash(ballot_init_cl)) }; 114 | } 115 | 116 | }} // namespace tvm::schema 117 | 118 | -------------------------------------------------------------------------------- /governance/SMV/MultiBallot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/MultiBallot.tvc -------------------------------------------------------------------------------- /governance/SMV/ProposalRoot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "deployProposal", 11 | "inputs": [ 12 | ], 13 | "outputs": [ 14 | ], 15 | "id": "0xb" 16 | }, 17 | { 18 | "name": "vote", 19 | "inputs": [ 20 | { "name":"_answer_id", "type":"uint32" }, 21 | { "name":"pubkey", "type":"uint256" }, 22 | { "name":"deposit", "type":"uint256" }, 23 | { "name":"yes", "type":"bool" } 24 | ], 25 | "outputs": [ 26 | { "name":"yes", "type":"uint128" }, 27 | { "name":"no", "type":"uint128" } 28 | ], 29 | "id": "0xc" 30 | }, 31 | { 32 | "name": "checkFinished", 33 | "inputs": [ 34 | { "name":"_answer_id", "type":"uint32" } 35 | ], 36 | "outputs": [ 37 | { "name":"value0", "type":"bool" } 38 | ], 39 | "id": "0xd" 40 | }, 41 | { 42 | "name": "checkApproved", 43 | "inputs": [ 44 | { "name":"_answer_id", "type":"uint32" } 45 | ], 46 | "outputs": [ 47 | { "name":"value0", "type":"bool" } 48 | ], 49 | "id": "0xe" 50 | }, 51 | { 52 | "name": "checkResults", 53 | "inputs": [ 54 | { "name":"_answer_id", "type":"uint32" } 55 | ], 56 | "outputs": [ 57 | { "name":"yes", "type":"uint128" }, 58 | { "name":"no", "type":"uint128" }, 59 | { "name":"finished", "type":"bool" }, 60 | { "name":"approved", "type":"bool" } 61 | ], 62 | "id": "0xf" 63 | }, 64 | { 65 | "name": "contestApproved", 66 | "inputs": [ 67 | ], 68 | "outputs": [ 69 | ], 70 | "id": "0x10" 71 | }, 72 | { 73 | "name": "getDepool", 74 | "inputs": [ 75 | ], 76 | "outputs": [ 77 | { "name":"value0", "type":"address" } 78 | ] 79 | }, 80 | { 81 | "name": "getVotePrice", 82 | "inputs": [ 83 | ], 84 | "outputs": [ 85 | { "name":"value0", "type":"uint256" } 86 | ] 87 | }, 88 | { 89 | "name": "getProposal", 90 | "inputs": [ 91 | ], 92 | "outputs": [ 93 | { "name":"id", "type":"uint256" }, 94 | { "name":"start", "type":"uint32" }, 95 | { "name":"end", "type":"uint32" }, 96 | { "name":"desc", "type":"bytes" }, 97 | { "name":"finished", "type":"bool" }, 98 | { "name":"approved", "type":"bool" }, 99 | { "name":"resultsSent", "type":"bool" }, 100 | { "name":"earlyFinished", "type":"bool" }, 101 | { "name":"whiteListEnabled", "type":"bool" }, 102 | { "name":"totalVotes", "type":"uint128" }, 103 | { "name":"currentVotes", "type":"uint128" }, 104 | { "name":"yesVotes", "type":"uint128" }, 105 | { "name":"noVotes", "type":"uint128" }, 106 | { "name":"votePrice", "type":"uint256" } 107 | ] 108 | }, 109 | { 110 | "name": "getWhiteList", 111 | "inputs": [ 112 | ], 113 | "outputs": [ 114 | { "name":"value0", "type":"uint256[]" } 115 | ] 116 | } 117 | ], 118 | "events": [ { 119 | "name": "VotesChanged", 120 | "inputs": [ 121 | { "name":"yes", "type":"uint128" }, 122 | { "name":"no", "type":"uint128" } 123 | ], 124 | "outputs": [ 125 | ], 126 | "id": "0x1e" 127 | }, 128 | { 129 | "name": "VotingFinished", 130 | "inputs": [ 131 | { "name":"yes", "type":"uint128" }, 132 | { "name":"no", "type":"uint128" }, 133 | { "name":"approved", "type":"bool" } 134 | ], 135 | "outputs": [ 136 | ], 137 | "id": "0x1f" 138 | } 139 | ] 140 | } 141 | -------------------------------------------------------------------------------- /governance/SMV/ProposalRoot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/ProposalRoot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/MultiBallot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "deployBallot", 11 | "inputs": [ 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "receiveNativeTransfer", 18 | "inputs": [ 19 | { "name":"amount", "type":"uint256" } 20 | ], 21 | "outputs": [ 22 | ] 23 | }, 24 | { 25 | "name": "receiveStakeTransfer", 26 | "inputs": [ 27 | { "name":"source", "type":"address" }, 28 | { "name":"amount", "type":"uint128" } 29 | ], 30 | "outputs": [ 31 | ], 32 | "id": "0x23c4771d" 33 | }, 34 | { 35 | "name": "sendVote", 36 | "inputs": [ 37 | { "name":"proposal", "type":"address" }, 38 | { "name":"yesOrNo", "type":"bool" } 39 | ], 40 | "outputs": [ 41 | { "name":"has_deposit", "type":"uint256" }, 42 | { "name":"already_sent_deposit", "type":"uint256" }, 43 | { "name":"new_sent_deposit", "type":"uint256" } 44 | ] 45 | }, 46 | { 47 | "name": "requestDeposit", 48 | "inputs": [ 49 | { "name":"user_wallet", "type":"address" } 50 | ], 51 | "outputs": [ 52 | ] 53 | }, 54 | { 55 | "name": "finalize", 56 | "inputs": [ 57 | { "name":"user_wallet", "type":"address" } 58 | ], 59 | "outputs": [ 60 | ] 61 | }, 62 | { 63 | "name": "getDepool", 64 | "inputs": [ 65 | ], 66 | "outputs": [ 67 | { "name":"value0", "type":"address" } 68 | ] 69 | }, 70 | { 71 | "name": "getNativeDeposit", 72 | "inputs": [ 73 | ], 74 | "outputs": [ 75 | { "name":"value0", "type":"uint256" } 76 | ] 77 | }, 78 | { 79 | "name": "getStakeDeposit", 80 | "inputs": [ 81 | ], 82 | "outputs": [ 83 | { "name":"value0", "type":"uint256" } 84 | ] 85 | }, 86 | { 87 | "name": "getMultiBallot_receiveNativeTransfer_GasPrice", 88 | "inputs": [ 89 | ], 90 | "outputs": [ 91 | { "name":"value0", "type":"uint256" } 92 | ] 93 | }, 94 | { 95 | "name": "getMultiBallot_receiveStakeTransfer_GasPrice", 96 | "inputs": [ 97 | ], 98 | "outputs": [ 99 | { "name":"value0", "type":"uint256" } 100 | ] 101 | } 102 | ], 103 | "events": [ 104 | ] 105 | } 106 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/ProposalRoot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "deployProposal", 11 | "inputs": [ 12 | ], 13 | "outputs": [ 14 | ], 15 | "id": "0xb" 16 | }, 17 | { 18 | "name": "vote", 19 | "inputs": [ 20 | { "name":"_answer_id", "type":"uint32" }, 21 | { "name":"pubkey", "type":"uint256" }, 22 | { "name":"deposit", "type":"uint256" }, 23 | { "name":"yes", "type":"bool" } 24 | ], 25 | "outputs": [ 26 | { "name":"yes", "type":"uint128" }, 27 | { "name":"no", "type":"uint128" } 28 | ], 29 | "id": "0xc" 30 | }, 31 | { 32 | "name": "checkFinished", 33 | "inputs": [ 34 | { "name":"_answer_id", "type":"uint32" } 35 | ], 36 | "outputs": [ 37 | { "name":"value0", "type":"bool" } 38 | ], 39 | "id": "0xd" 40 | }, 41 | { 42 | "name": "checkApproved", 43 | "inputs": [ 44 | { "name":"_answer_id", "type":"uint32" } 45 | ], 46 | "outputs": [ 47 | { "name":"value0", "type":"bool" } 48 | ], 49 | "id": "0xe" 50 | }, 51 | { 52 | "name": "checkResults", 53 | "inputs": [ 54 | { "name":"_answer_id", "type":"uint32" } 55 | ], 56 | "outputs": [ 57 | { "name":"yes", "type":"uint128" }, 58 | { "name":"no", "type":"uint128" }, 59 | { "name":"finished", "type":"bool" }, 60 | { "name":"approved", "type":"bool" } 61 | ], 62 | "id": "0xf" 63 | }, 64 | { 65 | "name": "contestApproved", 66 | "inputs": [ 67 | ], 68 | "outputs": [ 69 | ], 70 | "id": "0x10" 71 | }, 72 | { 73 | "name": "getDepool", 74 | "inputs": [ 75 | ], 76 | "outputs": [ 77 | { "name":"value0", "type":"address" } 78 | ] 79 | }, 80 | { 81 | "name": "getVotePrice", 82 | "inputs": [ 83 | ], 84 | "outputs": [ 85 | { "name":"value0", "type":"uint256" } 86 | ] 87 | }, 88 | { 89 | "name": "getProposal", 90 | "inputs": [ 91 | ], 92 | "outputs": [ 93 | { "name":"id", "type":"uint256" }, 94 | { "name":"start", "type":"uint32" }, 95 | { "name":"end", "type":"uint32" }, 96 | { "name":"desc", "type":"bytes" }, 97 | { "name":"finished", "type":"bool" }, 98 | { "name":"approved", "type":"bool" }, 99 | { "name":"resultsSent", "type":"bool" }, 100 | { "name":"earlyFinished", "type":"bool" }, 101 | { "name":"whiteListEnabled", "type":"bool" }, 102 | { "name":"totalVotes", "type":"uint128" }, 103 | { "name":"currentVotes", "type":"uint128" }, 104 | { "name":"yesVotes", "type":"uint128" }, 105 | { "name":"noVotes", "type":"uint128" }, 106 | { "name":"votePrice", "type":"uint256" } 107 | ] 108 | }, 109 | { 110 | "name": "getWhiteList", 111 | "inputs": [ 112 | ], 113 | "outputs": [ 114 | { "name":"value0", "type":"uint256[]" } 115 | ] 116 | } 117 | ], 118 | "events": [ { 119 | "name": "VotesChanged", 120 | "inputs": [ 121 | { "name":"yes", "type":"uint128" }, 122 | { "name":"no", "type":"uint128" } 123 | ], 124 | "outputs": [ 125 | ], 126 | "id": "0x1e" 127 | }, 128 | { 129 | "name": "VotingFinished", 130 | "inputs": [ 131 | { "name":"yes", "type":"uint128" }, 132 | { "name":"no", "type":"uint128" }, 133 | { "name":"approved", "type":"bool" } 134 | ], 135 | "outputs": [ 136 | ], 137 | "id": "0x1f" 138 | } 139 | ] 140 | } 141 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/SMVStats.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "time", 5 | "expire" 6 | ], 7 | "functions": [ 8 | { 9 | "name": "constructor", 10 | "inputs": [ 11 | { "name":"SMV_root", "type":"address" } 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "registerTransfer", 18 | "inputs": [ 19 | { "name":"_answer_id", "type":"uint32" }, 20 | { "name":"proposalId", "type":"uint256" }, 21 | { "name":"contestAddr", "type":"address" }, 22 | { "name":"requestValue", "type":"uint256" } 23 | ], 24 | "outputs": [ 25 | { "name":"value0", "type":"bool" } 26 | ] 27 | }, 28 | { 29 | "name": "getTransfers", 30 | "inputs": [ 31 | ], 32 | "outputs": [ 33 | { "components":[ 34 | { "name":"proposalId", "type":"uint256" }, 35 | { "name":"contestAddr", "type":"address" }, 36 | { "name":"requestValue", "type":"uint256" } 37 | ], "name":"value0", "type":"tuple[]" } 38 | ] 39 | } 40 | ], 41 | "events": [ 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/SuperRoot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"budget", "type":"address" }, 13 | { "name":"stats", "type":"address" }, 14 | { "name":"depool", "type":"address" } 15 | ], 16 | "outputs": [ 17 | ] 18 | }, 19 | { 20 | "name": "setProposalRootCode", 21 | "inputs": [ 22 | { "name":"code", "type":"cell" } 23 | ], 24 | "outputs": [ 25 | ] 26 | }, 27 | { 28 | "name": "setMultiBallotCode", 29 | "inputs": [ 30 | { "name":"code", "type":"cell" } 31 | ], 32 | "outputs": [ 33 | ] 34 | }, 35 | { 36 | "name": "createProposal", 37 | "inputs": [ 38 | { "name":"id", "type":"uint256" }, 39 | { "name":"totalVotes", "type":"uint128" }, 40 | { "name":"startime", "type":"uint32" }, 41 | { "name":"endtime", "type":"uint32" }, 42 | { "name":"desc", "type":"bytes" }, 43 | { "name":"superMajority", "type":"bool" }, 44 | { "name":"votePrice", "type":"uint256" }, 45 | { "name":"finalMsgEnabled", "type":"bool" }, 46 | { "name":"finalMsg", "type":"cell" }, 47 | { "name":"finalMsgValue", "type":"uint256" }, 48 | { "name":"finalMsgRequestValue", "type":"uint256" }, 49 | { "name":"whiteListEnabled", "type":"bool" }, 50 | { "name":"whitePubkeys", "type":"uint256[]" } 51 | ], 52 | "outputs": [ 53 | { "name":"value0", "type":"bool" } 54 | ] 55 | }, 56 | { 57 | "name": "createMultiBallot", 58 | "inputs": [ 59 | { "name":"pubkey", "type":"uint256" }, 60 | { "name":"tonsToBallot", "type":"uint256" } 61 | ], 62 | "outputs": [ 63 | { "name":"value0", "type":"address" } 64 | ] 65 | }, 66 | { 67 | "name": "contestApproved", 68 | "inputs": [ 69 | { "name":"id", "type":"uint256" }, 70 | { "name":"contest_addr", "type":"address" }, 71 | { "name":"requestValue", "type":"uint256" } 72 | ], 73 | "outputs": [ 74 | ] 75 | }, 76 | { 77 | "name": "getBudget", 78 | "inputs": [ 79 | ], 80 | "outputs": [ 81 | { "name":"value0", "type":"address" } 82 | ] 83 | }, 84 | { 85 | "name": "getStats", 86 | "inputs": [ 87 | ], 88 | "outputs": [ 89 | { "name":"value0", "type":"address" } 90 | ] 91 | }, 92 | { 93 | "name": "getDepool", 94 | "inputs": [ 95 | ], 96 | "outputs": [ 97 | { "name":"value0", "type":"address" } 98 | ] 99 | }, 100 | { 101 | "name": "getMultiBallotAddress", 102 | "inputs": [ 103 | { "name":"pubkey", "type":"uint256" } 104 | ], 105 | "outputs": [ 106 | { "name":"value0", "type":"address" } 107 | ] 108 | }, 109 | { 110 | "name": "getProposalById", 111 | "inputs": [ 112 | { "name":"id", "type":"uint256" } 113 | ], 114 | "outputs": [ 115 | { "name":"root", "type":"address" } 116 | ] 117 | }, 118 | { 119 | "name": "getProposalIds", 120 | "inputs": [ 121 | ], 122 | "outputs": [ 123 | { "name":"value0", "type":"uint256[]" } 124 | ] 125 | }, 126 | { 127 | "name": "getProposalAddress", 128 | "inputs": [ 129 | { "name":"id", "type":"uint256" } 130 | ], 131 | "outputs": [ 132 | { "name":"value0", "type":"address" } 133 | ] 134 | }, 135 | { 136 | "name": "isFullyInitialized", 137 | "inputs": [ 138 | ], 139 | "outputs": [ 140 | { "name":"value0", "type":"bool" } 141 | ] 142 | }, 143 | { 144 | "name": "getCreateMultiBallotGasPrice", 145 | "inputs": [ 146 | ], 147 | "outputs": [ 148 | { "name":"value0", "type":"uint256" } 149 | ] 150 | } 151 | ], 152 | "events": [ 153 | ] 154 | } 155 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/deployProposal/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=deployProposalDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":1000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[CREATE PROPOSAL DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | echo DEPLOY DEBOT 33 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 34 | target_abi=$(cat ../SuperRoot.abi | xxd -ps -c 20000) 35 | 36 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":0,\"debotAbi\":\"\",\"targetAddr\":\"\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 37 | echo SET DEBOT ABI 38 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 39 | echo SET TARGET ABI 40 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 41 | 42 | echo SET MSIG DEBOT ADDRESS 43 | $CLI_PATH/tonos-cli call $debot_address setMsigDebot "{\"md\":\"$MSIG_DEBOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 44 | echo SET SUPERROOT ADDRESS 45 | $CLI_PATH/tonos-cli call $debot_address setSuperRootAddress "{\"adr\":\"$SUPER_ROOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 46 | 47 | echo DONE 48 | echo $debot_address > address.log 49 | 50 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/deployProposal/deployProposalDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/deployProposal/deployProposalDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/deployall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | #input 4 | export CLI_PATH=~/test/tonos-cli/target/release 5 | export LOCAL_GIVER_PATH=~/givers/local_giver/ 6 | export NET_GIVER_PATH=~/givers/net_giver/ 7 | 8 | #export DEPLOY_LOCAL=1 9 | export SUPER_ROOT_ADDRESS=0:4e1bcac1f07ab3d139fac4c524716e66c94f74bd13b5608a8ef579a7f3b06c57 10 | export SMV_STAT_ADDRESS=0:6a01c3ebee13eba6732929e54bb43996ed90c9e90ebcdf4333962c95a3f4bd6b 11 | 12 | cd msigHelper 13 | ./deploy.sh 14 | cd .. 15 | 16 | export MSIG_DEBOT_ADDRESS=$(cat msigHelper/address.log) 17 | 18 | cd deployProposal 19 | ./deploy.sh 20 | cd .. 21 | 22 | cd smvStats 23 | ./deploy.sh 24 | cd .. 25 | 26 | cd proposalRoot 27 | ./deploy.sh 28 | cd .. 29 | 30 | cd multiballot 31 | ./deploy.sh 32 | cd .. 33 | 34 | cd superRoot 35 | ./deploy.sh 36 | cd .. 37 | 38 | echo EVERYTHING DONE 39 | 40 | 41 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/msigHelper/SafeMultisigWallet.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"owners","type":"uint256[]"}, 9 | {"name":"reqConfirms","type":"uint8"} 10 | ], 11 | "outputs": [ 12 | ] 13 | }, 14 | { 15 | "name": "acceptTransfer", 16 | "inputs": [ 17 | {"name":"payload","type":"bytes"} 18 | ], 19 | "outputs": [ 20 | ] 21 | }, 22 | { 23 | "name": "sendTransaction", 24 | "inputs": [ 25 | {"name":"dest","type":"address"}, 26 | {"name":"value","type":"uint128"}, 27 | {"name":"bounce","type":"bool"}, 28 | {"name":"flags","type":"uint8"}, 29 | {"name":"payload","type":"cell"} 30 | ], 31 | "outputs": [ 32 | ] 33 | }, 34 | { 35 | "name": "submitTransaction", 36 | "inputs": [ 37 | {"name":"dest","type":"address"}, 38 | {"name":"value","type":"uint128"}, 39 | {"name":"bounce","type":"bool"}, 40 | {"name":"allBalance","type":"bool"}, 41 | {"name":"payload","type":"cell"} 42 | ], 43 | "outputs": [ 44 | {"name":"transId","type":"uint64"} 45 | ] 46 | }, 47 | { 48 | "name": "confirmTransaction", 49 | "inputs": [ 50 | {"name":"transactionId","type":"uint64"} 51 | ], 52 | "outputs": [ 53 | ] 54 | }, 55 | { 56 | "name": "isConfirmed", 57 | "inputs": [ 58 | {"name":"mask","type":"uint32"}, 59 | {"name":"index","type":"uint8"} 60 | ], 61 | "outputs": [ 62 | {"name":"confirmed","type":"bool"} 63 | ] 64 | }, 65 | { 66 | "name": "getParameters", 67 | "inputs": [ 68 | ], 69 | "outputs": [ 70 | {"name":"maxQueuedTransactions","type":"uint8"}, 71 | {"name":"maxCustodianCount","type":"uint8"}, 72 | {"name":"expirationTime","type":"uint64"}, 73 | {"name":"minValue","type":"uint128"}, 74 | {"name":"requiredTxnConfirms","type":"uint8"} 75 | ] 76 | }, 77 | { 78 | "name": "getTransaction", 79 | "inputs": [ 80 | {"name":"transactionId","type":"uint64"} 81 | ], 82 | "outputs": [ 83 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"trans","type":"tuple"} 84 | ] 85 | }, 86 | { 87 | "name": "getTransactions", 88 | "inputs": [ 89 | ], 90 | "outputs": [ 91 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"transactions","type":"tuple[]"} 92 | ] 93 | }, 94 | { 95 | "name": "getTransactionIds", 96 | "inputs": [ 97 | ], 98 | "outputs": [ 99 | {"name":"ids","type":"uint64[]"} 100 | ] 101 | }, 102 | { 103 | "name": "getCustodians", 104 | "inputs": [ 105 | ], 106 | "outputs": [ 107 | {"components":[{"name":"index","type":"uint8"},{"name":"pubkey","type":"uint256"}],"name":"custodians","type":"tuple[]"} 108 | ] 109 | } 110 | ], 111 | "data": [ 112 | ], 113 | "events": [ 114 | { 115 | "name": "TransferAccepted", 116 | "inputs": [ 117 | {"name":"payload","type":"bytes"} 118 | ], 119 | "outputs": [ 120 | ] 121 | } 122 | ] 123 | } 124 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/msigHelper/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=msigHelperDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":5000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[MULTISIG HELPER DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | echo DEPLOY DEBOT 33 | target_abi=$(cat SafeMultisigWallet.abi.json | xxd -ps -c 20000) 34 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 35 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":0,\"debotAbi\":\"\",\"targetAddr\":\"\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 36 | echo SET DEBOT ABI 37 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 38 | echo SET TARGET ABI 39 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 40 | echo DONE 41 | echo $debot_address > address.log 42 | 43 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/msigHelper/msigHelperDebot.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"options","type":"uint8"}, 9 | {"name":"debotAbi","type":"bytes"}, 10 | {"name":"targetAbi","type":"bytes"}, 11 | {"name":"targetAddr","type":"address"} 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "setABI", 18 | "inputs": [ 19 | {"name":"dabi","type":"bytes"} 20 | ], 21 | "outputs": [ 22 | ] 23 | }, 24 | { 25 | "name": "setTargetABI", 26 | "inputs": [ 27 | {"name":"tabi","type":"bytes"} 28 | ], 29 | "outputs": [ 30 | ] 31 | }, 32 | { 33 | "name": "fetch", 34 | "inputs": [ 35 | ], 36 | "outputs": [ 37 | {"components":[{"name":"id","type":"uint8"},{"name":"desc","type":"bytes"},{"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"actions","type":"tuple[]"}],"name":"contexts","type":"tuple[]"} 38 | ] 39 | }, 40 | { 41 | "name": "getVersion", 42 | "inputs": [ 43 | ], 44 | "outputs": [ 45 | {"name":"name","type":"bytes"}, 46 | {"name":"semver","type":"uint24"} 47 | ] 48 | }, 49 | { 50 | "name": "quit", 51 | "inputs": [ 52 | ], 53 | "outputs": [ 54 | ] 55 | }, 56 | { 57 | "name": "getErrorDescription", 58 | "inputs": [ 59 | {"name":"error","type":"uint32"} 60 | ], 61 | "outputs": [ 62 | {"name":"desc","type":"bytes"} 63 | ] 64 | }, 65 | { 66 | "name": "sendSendTransactionEx", 67 | "inputs": [ 68 | {"name":"misc","type":"cell"} 69 | ], 70 | "outputs": [ 71 | {"name":"dest","type":"address"}, 72 | {"name":"body","type":"cell"} 73 | ] 74 | }, 75 | { 76 | "name": "sendSubmitMsgEx", 77 | "inputs": [ 78 | {"name":"misc","type":"cell"} 79 | ], 80 | "outputs": [ 81 | {"name":"dest","type":"address"}, 82 | {"name":"body","type":"cell"} 83 | ] 84 | }, 85 | { 86 | "name": "getDebotOptions", 87 | "inputs": [ 88 | ], 89 | "outputs": [ 90 | {"name":"options","type":"uint8"}, 91 | {"name":"debotAbi","type":"bytes"}, 92 | {"name":"targetAbi","type":"bytes"}, 93 | {"name":"targetAddr","type":"address"} 94 | ] 95 | } 96 | ], 97 | "data": [ 98 | ], 99 | "events": [ 100 | ] 101 | } 102 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/msigHelper/msigHelperDebot.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.6.0; 2 | pragma AbiHeader expire; 3 | pragma AbiHeader time; 4 | pragma AbiHeader pubkey; 5 | import "Debot.sol"; 6 | 7 | interface IMultisig { 8 | function submitTransaction( 9 | address dest, 10 | uint128 value, 11 | bool bounce, 12 | bool allBalance, 13 | TvmCell payload) 14 | external returns (uint64 transId); 15 | 16 | function sendTransaction( 17 | address dest, 18 | uint128 value, 19 | bool bounce, 20 | uint8 flags, 21 | TvmCell payload) external; 22 | } 23 | 24 | contract MultisigHelperDebot is Debot, DError { 25 | 26 | // helper modifier 27 | modifier accept() { 28 | tvm.accept(); 29 | _; 30 | } 31 | 32 | /* 33 | * Init functions 34 | */ 35 | 36 | constructor(uint8 options, string debotAbi, string targetAbi, address targetAddr) public { 37 | require(tvm.pubkey() == msg.pubkey(), 100); 38 | tvm.accept(); 39 | init(options, debotAbi, targetAbi, targetAddr); 40 | } 41 | 42 | function setABI(string dabi) public { 43 | require(tvm.pubkey() == msg.pubkey(), 100); 44 | tvm.accept(); 45 | m_debotAbi.set(dabi); 46 | m_options |= DEBOT_ABI; 47 | } 48 | 49 | function setTargetABI(string tabi) public { 50 | require(tvm.pubkey() == msg.pubkey(), 100); 51 | tvm.accept(); 52 | m_targetAbi.set(tabi); 53 | m_options |= DEBOT_TARGET_ABI; 54 | } 55 | 56 | /* 57 | * Overrided Debot functions 58 | */ 59 | 60 | function fetch() public override accept returns (Context[] contexts) { 61 | // Zero state: work with existing wallet or deploy new one. 62 | contexts.push(Context(STATE_ZERO, 63 | "Hello, I'm a Multisig Helper Debot. I'm created to be invoked! Have a nice day!", [ 64 | ActionPrint("Quit", "quit", STATE_EXIT) ] )); 65 | 66 | } 67 | 68 | function getVersion() public override accept returns (string name, uint24 semver) { 69 | name = "Multisig Helper DeBot"; 70 | semver = (1 << 8) | 0; 71 | } 72 | 73 | function quit() public override accept { } 74 | 75 | function getErrorDescription(uint32 error) public view override returns (string desc) { 76 | return "unknown exception! Code: "+string(error); 77 | } 78 | 79 | /* 80 | * Send message handlers 81 | */ 82 | 83 | function sendSendTransactionEx(TvmCell misc) public accept pure returns (address dest, TvmCell body) { 84 | (address wallet, address recipient, uint64 amount, uint8 bounce, uint8 flags, TvmCell payload) = 85 | misc.toSlice().decode(address, address, uint64, uint8, uint8, TvmCell); 86 | dest = wallet; 87 | body = tvm.encodeBody(IMultisig.sendTransaction, 88 | recipient, amount, 89 | bounce == 1 ? true : false, 90 | flags, 91 | payload 92 | ); 93 | } 94 | 95 | function sendSubmitMsgEx(TvmCell misc) public accept pure returns (address dest, TvmCell body) { 96 | (address wallet, address recipient, uint64 amount, uint8 bounce, uint8 allBalance, TvmCell payload) = 97 | misc.toSlice().decode(address, address, uint64, uint8, uint8, TvmCell); 98 | dest = wallet; 99 | body = tvm.encodeBody(IMultisig.submitTransaction, 100 | recipient, amount, 101 | bounce == 1 ? true : false, 102 | allBalance == 1 ? true : false, 103 | payload 104 | ); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/msigHelper/msigHelperDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/msigHelper/msigHelperDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/multiballot/MultiBallotDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/multiballot/MultiBallotDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/multiballot/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=MultiBallotDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":5000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[MULTIBALLOT DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | sleep 1 33 | echo DEPLOY DEBOT 34 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 35 | target_abi=$(cat ../MultiBallot.abi | xxd -ps -c 20000) 36 | 37 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":0,\"debotAbi\":\"\",\"targetAddr\":\"\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 38 | echo SET DEBOT ABI 39 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 40 | echo SET TARGET ABI 41 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 42 | echo SET MSIG DEBOT ADDRESS 43 | $CLI_PATH/tonos-cli call $debot_address setMsigDebot "{\"md\":\"$MSIG_DEBOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 44 | echo SET MULTIBALOT 45 | $CLI_PATH/tonos-cli call $debot_address setMbAbi "{\"dabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 46 | echo SET SUPERROOT 47 | sr_abi=$(cat ../SuperRoot.abi | xxd -ps -c 20000) 48 | $CLI_PATH/tonos-cli call $debot_address setSrAbi "{\"dabi\":\"$sr_abi\"}" --sign $filenamekeys --abi $filenameabi 49 | $CLI_PATH/tonos-cli call $debot_address setSrAddr "{\"addr\":\"$SUPER_ROOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 50 | echo SET PROPOSALROOT 51 | pr_abi=$(cat ../ProposalRoot.abi | xxd -ps -c 20000) 52 | $CLI_PATH/tonos-cli call $debot_address setPrAbi "{\"dabi\":\"$pr_abi\"}" --sign $filenamekeys --abi $filenameabi 53 | 54 | echo DONE 55 | echo $debot_address > address.log 56 | 57 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/proposalRoot/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=proposalRootDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":1000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":1000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[PROPOSALROOT DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | echo DEPLOY DEBOT 33 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 34 | target_abi=$(cat ../ProposalRoot.abi | xxd -ps -c 20000) 35 | 36 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":0,\"debotAbi\":\"\",\"targetAddr\":\"\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 37 | echo SET DEBOT ABI 38 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 39 | echo SET TARGET ABI 40 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 41 | 42 | 43 | echo DONE 44 | echo $debot_address > address.log 45 | 46 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/proposalRoot/proposalRootDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/proposalRoot/proposalRootDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo RUN DEBOT 4 | debot_address=$(cat ./superRoot/address.log) 5 | echo $debot_address 6 | ~/test/tonos-cli/target/release/tonos-cli debot fetch $debot_address 7 | 8 | 9 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/smvStats/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=smvStatDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":1000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":1000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[SMVSTAT DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | echo DEPLOY DEBOT 33 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 34 | target_abi=$(cat ../SMVStats.abi | xxd -ps -c 20000) 35 | 36 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":4,\"debotAbi\":\"\",\"targetAddr\":\"$SMV_STAT_ADDRESS\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 37 | echo SET DEBOT ABI 38 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 39 | echo SET TARGET ABI 40 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 41 | 42 | 43 | echo DONE 44 | echo $debot_address > address.log 45 | 46 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/smvStats/smvStatDebot.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"options","type":"uint8"}, 9 | {"name":"debotAbi","type":"bytes"}, 10 | {"name":"targetAbi","type":"bytes"}, 11 | {"name":"targetAddr","type":"address"} 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "setABI", 18 | "inputs": [ 19 | {"name":"dabi","type":"bytes"} 20 | ], 21 | "outputs": [ 22 | ] 23 | }, 24 | { 25 | "name": "setTargetABI", 26 | "inputs": [ 27 | {"name":"tabi","type":"bytes"} 28 | ], 29 | "outputs": [ 30 | ] 31 | }, 32 | { 33 | "name": "fetch", 34 | "inputs": [ 35 | ], 36 | "outputs": [ 37 | {"components":[{"name":"id","type":"uint8"},{"name":"desc","type":"bytes"},{"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"actions","type":"tuple[]"}],"name":"contexts","type":"tuple[]"} 38 | ] 39 | }, 40 | { 41 | "name": "getVersion", 42 | "inputs": [ 43 | ], 44 | "outputs": [ 45 | {"name":"name","type":"bytes"}, 46 | {"name":"semver","type":"uint24"} 47 | ] 48 | }, 49 | { 50 | "name": "quit", 51 | "inputs": [ 52 | ], 53 | "outputs": [ 54 | ] 55 | }, 56 | { 57 | "name": "getErrorDescription", 58 | "inputs": [ 59 | {"name":"error","type":"uint32"} 60 | ], 61 | "outputs": [ 62 | {"name":"desc","type":"bytes"} 63 | ] 64 | }, 65 | { 66 | "name": "setTransfers", 67 | "inputs": [ 68 | {"components":[{"name":"proposalId","type":"uint256"},{"name":"contestAddr","type":"address"},{"name":"requestValue","type":"uint256"}],"name":"value0","type":"tuple[]"} 69 | ], 70 | "outputs": [ 71 | ] 72 | }, 73 | { 74 | "name": "fetchTransfers", 75 | "inputs": [ 76 | ], 77 | "outputs": [ 78 | {"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"actions","type":"tuple[]"} 79 | ] 80 | }, 81 | { 82 | "name": "parseTransfer", 83 | "inputs": [ 84 | {"name":"misc","type":"cell"} 85 | ], 86 | "outputs": [ 87 | {"name":"number0","type":"uint256"}, 88 | {"name":"param1","type":"address"}, 89 | {"name":"number2","type":"uint64"}, 90 | {"name":"number3","type":"uint64"} 91 | ] 92 | }, 93 | { 94 | "name": "getDebotOptions", 95 | "inputs": [ 96 | ], 97 | "outputs": [ 98 | {"name":"options","type":"uint8"}, 99 | {"name":"debotAbi","type":"bytes"}, 100 | {"name":"targetAbi","type":"bytes"}, 101 | {"name":"targetAddr","type":"address"} 102 | ] 103 | } 104 | ], 105 | "data": [ 106 | ], 107 | "events": [ 108 | ] 109 | } 110 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/smvStats/smvStatDebot.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.6.0; 2 | pragma AbiHeader expire; 3 | pragma AbiHeader time; 4 | pragma AbiHeader pubkey; 5 | import "Debot.sol"; 6 | 7 | contract SMVStatDebot is Debot, DError { 8 | 9 | struct TransferInfo { 10 | uint256 proposalId; 11 | address contestAddr; 12 | uint256 requestValue; 13 | } 14 | 15 | TransferInfo[] m_Transfers; 16 | 17 | /* 18 | * Helper modifiers 19 | */ 20 | 21 | modifier onlyOwnerAccept() { 22 | require(tvm.pubkey() == msg.pubkey(), 100); 23 | tvm.accept(); 24 | _; 25 | } 26 | 27 | modifier accept() { 28 | tvm.accept(); 29 | _; 30 | } 31 | 32 | /* 33 | * Init functions 34 | */ 35 | 36 | constructor(uint8 options, string debotAbi, string targetAbi, address targetAddr) public onlyOwnerAccept { 37 | init(options, debotAbi, targetAbi, targetAddr); 38 | } 39 | 40 | function setABI(string dabi) public onlyOwnerAccept { 41 | m_debotAbi.set(dabi); 42 | m_options |= DEBOT_ABI; 43 | } 44 | 45 | function setTargetABI(string tabi) public onlyOwnerAccept { 46 | m_targetAbi.set(tabi); 47 | m_options |= DEBOT_TARGET_ABI; 48 | } 49 | 50 | /* 51 | * Derived Debot Functions 52 | */ 53 | 54 | function fetch() public override accept returns (Context[] contexts) { 55 | 56 | optional(string) empty; 57 | 58 | contexts.push(Context(STATE_ZERO, 59 | "", [ 60 | ActionGetMethod("querying smv stat...", "getTransfers", empty, 61 | "setTransfers", true, STATE_CURRENT), 62 | ActionInstantRun("", "fetchTransfers", STATE_CURRENT), 63 | ActionGoto("Return to main", STATE_EXIT) ] )); 64 | 65 | } 66 | 67 | function getVersion() public override accept returns (string name, uint24 semver) { 68 | name = "SMV Statistic DeBot"; 69 | semver = (0 << 8) | 1; 70 | } 71 | 72 | function quit() public override accept {} 73 | 74 | function getErrorDescription(uint32 error) public view override returns (string desc) { 75 | return "unknown exception"; 76 | } 77 | 78 | /* 79 | * Handlers 80 | */ 81 | 82 | function setTransfers(TransferInfo[] value0) public accept { 83 | m_Transfers = value0; 84 | } 85 | 86 | function fetchTransfers() public accept returns (Action[] actions) { 87 | for(uint256 i = 0; i < m_Transfers.length; i++) { 88 | Action act = ActionPrint("", "Transfer:\n proposal id: {}\n contest address: {}\n request value (ton): {}.{}", STATE_CURRENT); 89 | act.attrs = "instant,fargs=parseTransfer"; 90 | TvmBuilder ctx; 91 | ctx.store(m_Transfers[i].proposalId,m_Transfers[i].contestAddr,m_Transfers[i].requestValue); 92 | act.misc = ctx.toCell(); 93 | actions.push(act); 94 | } 95 | } 96 | 97 | function parseTransfer(TvmCell misc) public accept returns (uint256 number0, address param1, uint64 number2, uint64 number3) { 98 | uint256 t; 99 | (number0,param1,t) = misc.toSlice().decode(uint256,address,uint256); 100 | (number2, number3) = tokens(t); 101 | } 102 | 103 | function tokens(uint256 nanotokens) private pure returns (uint64, uint64) { 104 | uint64 decimal = uint64(nanotokens / 1e9); 105 | uint64 float = uint64(nanotokens - (decimal * 1e9)); 106 | return (decimal, float); 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/smvStats/smvStatDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/smvStats/smvStatDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/superRoot/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=superRootDebot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | function giver_local { 10 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":1000000000}" 11 | } 12 | function giver_net { 13 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 14 | } 15 | function get_address { 16 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 17 | } 18 | 19 | echo "" 20 | echo "[SUPER ROOT DEBOT]" 21 | echo "" 22 | 23 | echo GENADDR DEBOT 24 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 25 | debot_address=$(get_address) 26 | echo GIVER 27 | if [ "$DEPLOY_LOCAL" = "" ]; then 28 | giver_net $debot_address 29 | else 30 | giver_local $debot_address 31 | fi 32 | echo DEPLOY DEBOT 33 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 34 | target_abi=$(cat ../SuperRoot.abi | xxd -ps -c 20000) 35 | 36 | $CLI_PATH/tonos-cli deploy $filenametvc "{\"options\":0,\"debotAbi\":\"\",\"targetAddr\":\"\",\"targetAbi\":\"\"}" --sign $filenamekeys --abi $filenameabi 37 | echo SET DEBOT ABI 38 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 39 | echo SET TARGET ABI 40 | $CLI_PATH/tonos-cli call $debot_address setTargetABI "{\"tabi\":\"$target_abi\"}" --sign $filenamekeys --abi $filenameabi 41 | 42 | echo SET MSIG DEBOT ADDRESS 43 | $CLI_PATH/tonos-cli call $debot_address setMsigDebot "{\"md\":\"$MSIG_DEBOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 44 | echo SET SUPERROOT ADDRESS 45 | $CLI_PATH/tonos-cli call $debot_address setSuperRootAddress "{\"adr\":\"$SUPER_ROOT_ADDRESS\"}" --sign $filenamekeys --abi $filenameabi 46 | echo SET MULTIBALLOT DEBOT ADDRESS 47 | mb_deobt=$(cat ../multiballot/address.log) 48 | $CLI_PATH/tonos-cli call $debot_address setMultiballotDebot "{\"adr\":\"$mb_deobt\"}" --sign $filenamekeys --abi $filenameabi 49 | echo SET PROPOSALROOT DEBOT ADDRESS 50 | pr_deobt=$(cat ../proposalRoot/address.log) 51 | $CLI_PATH/tonos-cli call $debot_address setProposalDebot "{\"adr\":\"$pr_deobt\"}" --sign $filenamekeys --abi $filenameabi 52 | echo SET STAT DEBOT ADDRESS 53 | stat_debot=$(cat ../smvStats/address.log) 54 | $CLI_PATH/tonos-cli call $debot_address setStatDebot "{\"adr\":\"$stat_debot\"}" --sign $filenamekeys --abi $filenameabi 55 | echo SET DEPLOY PROPOSAL DEBOT ADDRESS 56 | dp_debot=$(cat ../deployProposal/address.log) 57 | $CLI_PATH/tonos-cli call $debot_address setDeployProposalDebot "{\"adr\":\"$dp_debot\"}" --sign $filenamekeys --abi $filenameabi 58 | 59 | 60 | echo DONE 61 | echo $debot_address > address.log 62 | 63 | -------------------------------------------------------------------------------- /governance/SMV/SMVDeBot/superRoot/superRootDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVDeBot/superRoot/superRootDebot.tvc -------------------------------------------------------------------------------- /governance/SMV/SMVStats.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "time", 5 | "expire" 6 | ], 7 | "functions": [ 8 | { 9 | "name": "constructor", 10 | "inputs": [ 11 | { "name":"SMV_root", "type":"address" } 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "registerTransfer", 18 | "inputs": [ 19 | { "name":"_answer_id", "type":"uint32" }, 20 | { "name":"proposalId", "type":"uint256" }, 21 | { "name":"contestAddr", "type":"address" }, 22 | { "name":"requestValue", "type":"uint256" } 23 | ], 24 | "outputs": [ 25 | { "name":"value0", "type":"bool" } 26 | ] 27 | }, 28 | { 29 | "name": "getTransfers", 30 | "inputs": [ 31 | ], 32 | "outputs": [ 33 | { "components":[ 34 | { "name":"proposalId", "type":"uint256" }, 35 | { "name":"contestAddr", "type":"address" }, 36 | { "name":"requestValue", "type":"uint256" } 37 | ], "name":"value0", "type":"tuple[]" } 38 | ] 39 | } 40 | ], 41 | "events": [ 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /governance/SMV/SMVStats.cpp: -------------------------------------------------------------------------------- 1 | #include "config.hpp" 2 | #include "SMVStats.hpp" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace tvm; 10 | using namespace schema; 11 | 12 | class SMVStats final : public smart_interface, public DSMVStats { 13 | public: 14 | struct error_code : tvm::error_code { 15 | static constexpr unsigned wrong_sender_address = 100; 16 | }; 17 | 18 | __always_inline 19 | void constructor(address SMV_root) { 20 | SMV_root_ = SMV_root; 21 | transfers_.reset(); 22 | start_balance_ = tvm_balance(); 23 | } 24 | 25 | __always_inline 26 | bool_t registerTransfer(uint256 proposalId, address contestAddr, uint256 requestValue) { 27 | require(int_sender() == SMV_root_, error_code::wrong_sender_address); 28 | 29 | auto [sender, value_gr] = int_sender_and_value(); 30 | tvm_rawreserve(std::max(start_balance_.get(), tvm_balance() - value_gr()), rawreserve_flag::up_to); 31 | 32 | auto addr = std::get(contestAddr.val()); 33 | 34 | transfers_.push_back(TransferRecord{proposalId, {addr.workchain_id, addr.address}, requestValue}); 35 | 36 | set_int_return_flag(INT_RETURN_FLAG); 37 | return bool_t{true}; 38 | } 39 | 40 | // ======= getters ======= 41 | __always_inline 42 | dict_array getTransfers() { 43 | dict_array rv; 44 | for (auto it = transfers_.rbegin(); it != transfers_.rend(); ++it) { 45 | auto rec = *it; 46 | rv.push_back( 47 | Transfer{rec.proposalId, 48 | address::make_std(rec.contestAddr.workchain_id, rec.contestAddr.address), 49 | rec.requestValue}); 50 | } 51 | return rv; 52 | } 53 | 54 | // ==================== Support methods =========================== // 55 | 56 | // default processing of unknown messages 57 | __always_inline static int _fallback(cell msg, slice msg_body) { 58 | return 0; 59 | } 60 | DEFAULT_SUPPORT_FUNCTIONS(ISMVStats, stats_replay_protection_t); 61 | }; 62 | 63 | DEFINE_JSON_ABI(ISMVStats, DSMVStats, ESMVStats); 64 | 65 | // ----------------------------- Main entry functions ---------------------- // 66 | DEFAULT_MAIN_ENTRY_FUNCTIONS(SMVStats, ISMVStats, DSMVStats, STATS_TIMESTAMP_DELAY) 67 | 68 | -------------------------------------------------------------------------------- /governance/SMV/SMVStats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace tvm { namespace schema { 10 | 11 | // For internal purposes (fixed-size address) 12 | struct TransferRecord { 13 | uint256 proposalId; 14 | addr_std_fixed contestAddr; 15 | uint256 requestValue; 16 | }; 17 | // For getter (reconstructed address) 18 | struct Transfer { 19 | uint256 proposalId; 20 | address contestAddr; 21 | uint256 requestValue; 22 | }; 23 | 24 | __interface [[no_pubkey]] ISMVStats { 25 | 26 | [[internal, external, dyn_chain_parse]] 27 | void constructor(address SMV_root); 28 | 29 | [[internal, noaccept, answer_id]] 30 | bool_t registerTransfer(uint256 proposalId, address contestAddr, uint256 requestValue); 31 | 32 | // ============== getters ============== 33 | [[getter]] 34 | dict_array getTransfers(); 35 | }; 36 | 37 | struct DSMVStats { 38 | address SMV_root_; 39 | log_sequence transfers_; 40 | Grams start_balance_; 41 | }; 42 | 43 | struct ESMVStats {}; 44 | 45 | static constexpr unsigned STATS_TIMESTAMP_DELAY = 1800; 46 | using stats_replay_protection_t = replay_attack_protection::timestamp; 47 | 48 | inline 49 | std::pair prepare_stats_state_init_and_addr(DSMVStats data, cell code) { 50 | cell data_cl = 51 | prepare_persistent_data( 52 | { stats_replay_protection_t::init() }, data); 53 | StateInit init { 54 | /*split_depth*/{}, /*special*/{}, 55 | code, data_cl, /*library*/{} 56 | }; 57 | cell init_cl = build(init).make_cell(); 58 | return { init, uint256(tvm_hash(init_cl)) }; 59 | } 60 | 61 | }} // namespace tvm::schema 62 | 63 | -------------------------------------------------------------------------------- /governance/SMV/SMVStats.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SMVStats.tvc -------------------------------------------------------------------------------- /governance/SMV/SuperRoot.abi: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": [ 4 | "pubkey", 5 | "time", 6 | "expire" 7 | ], 8 | "functions": [ 9 | { 10 | "name": "constructor", 11 | "inputs": [ 12 | { "name":"budget", "type":"address" }, 13 | { "name":"stats", "type":"address" }, 14 | { "name":"depool", "type":"address" } 15 | ], 16 | "outputs": [ 17 | ] 18 | }, 19 | { 20 | "name": "setProposalRootCode", 21 | "inputs": [ 22 | { "name":"code", "type":"cell" } 23 | ], 24 | "outputs": [ 25 | ] 26 | }, 27 | { 28 | "name": "setMultiBallotCode", 29 | "inputs": [ 30 | { "name":"code", "type":"cell" } 31 | ], 32 | "outputs": [ 33 | ] 34 | }, 35 | { 36 | "name": "createProposal", 37 | "inputs": [ 38 | { "name":"id", "type":"uint256" }, 39 | { "name":"totalVotes", "type":"uint128" }, 40 | { "name":"startime", "type":"uint32" }, 41 | { "name":"endtime", "type":"uint32" }, 42 | { "name":"desc", "type":"bytes" }, 43 | { "name":"superMajority", "type":"bool" }, 44 | { "name":"votePrice", "type":"uint256" }, 45 | { "name":"finalMsgEnabled", "type":"bool" }, 46 | { "name":"finalMsg", "type":"cell" }, 47 | { "name":"finalMsgValue", "type":"uint256" }, 48 | { "name":"finalMsgRequestValue", "type":"uint256" }, 49 | { "name":"whiteListEnabled", "type":"bool" }, 50 | { "name":"whitePubkeys", "type":"uint256[]" } 51 | ], 52 | "outputs": [ 53 | { "name":"value0", "type":"bool" } 54 | ] 55 | }, 56 | { 57 | "name": "createMultiBallot", 58 | "inputs": [ 59 | { "name":"pubkey", "type":"uint256" }, 60 | { "name":"tonsToBallot", "type":"uint256" } 61 | ], 62 | "outputs": [ 63 | { "name":"value0", "type":"address" } 64 | ] 65 | }, 66 | { 67 | "name": "contestApproved", 68 | "inputs": [ 69 | { "name":"id", "type":"uint256" }, 70 | { "name":"contest_addr", "type":"address" }, 71 | { "name":"requestValue", "type":"uint256" } 72 | ], 73 | "outputs": [ 74 | ] 75 | }, 76 | { 77 | "name": "getBudget", 78 | "inputs": [ 79 | ], 80 | "outputs": [ 81 | { "name":"value0", "type":"address" } 82 | ] 83 | }, 84 | { 85 | "name": "getStats", 86 | "inputs": [ 87 | ], 88 | "outputs": [ 89 | { "name":"value0", "type":"address" } 90 | ] 91 | }, 92 | { 93 | "name": "getDepool", 94 | "inputs": [ 95 | ], 96 | "outputs": [ 97 | { "name":"value0", "type":"address" } 98 | ] 99 | }, 100 | { 101 | "name": "getMultiBallotAddress", 102 | "inputs": [ 103 | { "name":"pubkey", "type":"uint256" } 104 | ], 105 | "outputs": [ 106 | { "name":"value0", "type":"address" } 107 | ] 108 | }, 109 | { 110 | "name": "getProposalById", 111 | "inputs": [ 112 | { "name":"id", "type":"uint256" } 113 | ], 114 | "outputs": [ 115 | { "name":"root", "type":"address" } 116 | ] 117 | }, 118 | { 119 | "name": "getProposalIds", 120 | "inputs": [ 121 | ], 122 | "outputs": [ 123 | { "name":"value0", "type":"uint256[]" } 124 | ] 125 | }, 126 | { 127 | "name": "getProposalAddress", 128 | "inputs": [ 129 | { "name":"id", "type":"uint256" } 130 | ], 131 | "outputs": [ 132 | { "name":"value0", "type":"address" } 133 | ] 134 | }, 135 | { 136 | "name": "isFullyInitialized", 137 | "inputs": [ 138 | ], 139 | "outputs": [ 140 | { "name":"value0", "type":"bool" } 141 | ] 142 | }, 143 | { 144 | "name": "getCreateMultiBallotGasPrice", 145 | "inputs": [ 146 | ], 147 | "outputs": [ 148 | { "name":"value0", "type":"uint256" } 149 | ] 150 | } 151 | ], 152 | "events": [ 153 | ] 154 | } 155 | -------------------------------------------------------------------------------- /governance/SMV/SuperRoot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MultiBallot.hpp" 4 | #include "Budget.hpp" 5 | #include "SMVStats.hpp" 6 | 7 | #include 8 | 9 | namespace tvm { namespace schema { 10 | 11 | struct Proposal { 12 | address root; 13 | }; 14 | 15 | __interface ISuperRoot { 16 | 17 | [[external, dyn_chain_parse]] 18 | void constructor(address budget, address stats, address depool); 19 | 20 | [[external, noaccept, dyn_chain_parse]] 21 | void setProposalRootCode(cell code); 22 | 23 | [[external, noaccept, dyn_chain_parse]] 24 | void setMultiBallotCode(cell code); 25 | 26 | // Adds new proposal to m_proposals, prepares initial data for new Proposal Root contract, 27 | // calculates it address and deploys it 28 | [[internal, noaccept, dyn_chain_parse]] 29 | bool_t createProposal(uint256 id, VotesType totalVotes, 30 | uint32 startime, uint32 endtime, bytes desc, 31 | bool_t superMajority, DepositType votePrice, 32 | bool_t finalMsgEnabled, 33 | cell finalMsg, uint256 finalMsgValue, uint256 finalMsgRequestValue, 34 | bool_t whiteListEnabled, dict_array whitePubkeys); 35 | 36 | // Create MultiBallot for user, to vote for proposals 37 | [[internal, noaccept, dyn_chain_parse]] 38 | address createMultiBallot(uint256 pubkey, DepositType tonsToBallot); 39 | 40 | // Proposal notifies that contest is approved and funds requested 41 | [[internal, noaccept]] 42 | void contestApproved(uint256 id, address contest_addr, uint256 requestValue); 43 | 44 | // ============== getters ============== 45 | [[getter]] 46 | address getBudget(); 47 | 48 | [[getter]] 49 | address getStats(); 50 | 51 | [[getter]] 52 | address getDepool(); 53 | 54 | [[getter]] 55 | address getMultiBallotAddress(uint256 pubkey); 56 | 57 | [[getter]] 58 | Proposal getProposalById(uint256 id); 59 | 60 | [[getter]] 61 | dict_array getProposalIds(); 62 | 63 | [[getter]] 64 | address getProposalAddress(uint256 id); 65 | 66 | [[getter]] 67 | bool_t isFullyInitialized(); 68 | 69 | [[getter, no_persistent]] 70 | DepositType getCreateMultiBallotGasPrice(); 71 | }; 72 | 73 | struct DSuperRoot { 74 | handle budget_; 75 | handle stats_; 76 | address depool_; 77 | std::optional proposal_root_code_; 78 | std::optional multi_ballot_code_; 79 | int8 workchain_id_; 80 | DepositType start_balance_; 81 | dict_map proposals_; 82 | uint256 deployer_key_; 83 | }; 84 | 85 | struct ESuperRoot {}; 86 | 87 | }} // namespace tvm::schema 88 | 89 | -------------------------------------------------------------------------------- /governance/SMV/SuperRoot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/governance/SMV/SuperRoot.tvc -------------------------------------------------------------------------------- /governance/SMV/config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace tvm { 7 | 8 | // without `SENDER_WANTS_TO_PAY_FEES_SEPARATELY` rawreserve + send_all_gas scheme doesn't work correctly in local node se 9 | static const unsigned INT_RETURN_FLAG = SEND_ALL_GAS | SENDER_WANTS_TO_PAY_FEES_SEPARATELY | IGNORE_ACTION_ERRORS; 10 | 11 | } // namespace tvm 12 | 13 | -------------------------------------------------------------------------------- /solidity/contest/FreeTonContest.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/contest/FreeTonContest.tvc -------------------------------------------------------------------------------- /solidity/contest/IBaseData.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >= 0.6.0; 2 | 3 | enum Stage { Undefined, Setup, Contest, Vote, Finalize, Rank, Reward, Finish, Reserved, Last } 4 | -------------------------------------------------------------------------------- /solidity/contest/IContestData.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >= 0.6.0; 2 | 3 | import "IBaseData.sol"; 4 | interface IContestData { 5 | 6 | /* General contest information */ 7 | struct ContestInfo { 8 | uint32 gid; // Contract global ID 9 | string title; // Title of the contract 10 | string link; // Link to the document location 11 | uint hash; // Hash of the proposal 12 | } 13 | 14 | struct Juror { 15 | uint key; // Juror's public key 16 | address addr; // Juror's address 17 | } 18 | 19 | /* Timeline of the contest */ 20 | struct ContestTimeline { 21 | uint32 createdAt; // Contest contract creation 22 | uint32 contestStarts; // Accepts contest entries 23 | uint32 contestEnds; // End of the acceptance period 24 | uint32 votingEnds; // End of the voting period 25 | } 26 | 27 | struct ContestStage { 28 | uint32 mask; 29 | uint32 notifyAt; 30 | } 31 | 32 | /* Individual contest entry */ 33 | struct ContenderInfo { 34 | address addr; // Rewards go there 35 | string forumLink; // forum post link 36 | string fileLink; // PDF document link 37 | uint hash; // hash of the PDF 38 | address contact; // Surf address contact (optional) 39 | uint32 appliedAt; // Timestamp of the entry arrival 40 | } 41 | } -------------------------------------------------------------------------------- /solidity/debots/ludi/ludiDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/debots/ludi/ludiDebot.tvc -------------------------------------------------------------------------------- /solidity/debots/msig/msigDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/debots/msig/msigDebot.tvc -------------------------------------------------------------------------------- /solidity/depool/DePool.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depool/DePool.tvc -------------------------------------------------------------------------------- /solidity/depool/DePoolHelper.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"pool","type":"address"} 9 | ], 10 | "outputs": [ 11 | ] 12 | }, 13 | { 14 | "name": "updateDePoolPoolAddress", 15 | "inputs": [ 16 | {"name":"addr","type":"address"} 17 | ], 18 | "outputs": [ 19 | ] 20 | }, 21 | { 22 | "name": "initTimer", 23 | "inputs": [ 24 | {"name":"timer","type":"address"}, 25 | {"name":"period","type":"uint256"} 26 | ], 27 | "outputs": [ 28 | ] 29 | }, 30 | { 31 | "name": "onTimer", 32 | "inputs": [ 33 | ], 34 | "outputs": [ 35 | ] 36 | }, 37 | { 38 | "name": "sendTicktock", 39 | "inputs": [ 40 | ], 41 | "outputs": [ 42 | ] 43 | }, 44 | { 45 | "name": "getDePoolPoolAddress", 46 | "inputs": [ 47 | ], 48 | "outputs": [ 49 | {"name":"addr","type":"address"} 50 | ] 51 | }, 52 | { 53 | "name": "getHistory", 54 | "inputs": [ 55 | ], 56 | "outputs": [ 57 | {"name":"list","type":"address[]"} 58 | ] 59 | }, 60 | { 61 | "name": "upgrade", 62 | "inputs": [ 63 | {"name":"newcode","type":"cell"} 64 | ], 65 | "outputs": [ 66 | ] 67 | }, 68 | { 69 | "name": "sendTransaction", 70 | "inputs": [ 71 | {"name":"dest","type":"address"}, 72 | {"name":"value","type":"uint64"}, 73 | {"name":"bounce","type":"bool"}, 74 | {"name":"flags","type":"uint16"}, 75 | {"name":"payload","type":"cell"} 76 | ], 77 | "outputs": [ 78 | ] 79 | } 80 | ], 81 | "data": [ 82 | ], 83 | "events": [ 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /solidity/depool/DePoolHelper.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >0.5.0; 4 | pragma AbiHeader expire; 5 | 6 | import "IDePool.sol"; 7 | import "Participant.sol"; 8 | 9 | interface ITimer { 10 | function setTimer(uint timer) external; 11 | } 12 | 13 | contract DePoolHelper is ParticipantContract { 14 | uint constant TICKTOCK_FEE = 1e9; 15 | 16 | // Timer fees 17 | uint constant _timerRate = 400000; // 400 000 nt = 400 mct = 0,4 mt = 0,0004 t per second 18 | uint constant _fwdFee = 1000000; // 1 000 000 nt = 1 000 mct = 1 mt = 0,001 t 19 | uint constant _epsilon = 1e9; 20 | 21 | // Actual DePool pool contract address. 22 | address m_dePoolPool; 23 | // Array of old (closed) DePool contract addresses. 24 | address[] m_poolHistory; 25 | // Timer contract address. 26 | address m_timer; 27 | // Timer timeout. 28 | uint m_timeout; 29 | 30 | constructor(address pool) public acceptOnlyOwner { 31 | m_dePoolPool = pool; 32 | } 33 | 34 | modifier acceptOnlyOwner { 35 | require(msg.pubkey() == tvm.pubkey(), 101); 36 | tvm.accept(); 37 | _; 38 | } 39 | 40 | /* 41 | public methods 42 | */ 43 | 44 | function updateDePoolPoolAddress(address addr) public acceptOnlyOwner { 45 | m_poolHistory.push(m_dePoolPool); 46 | m_dePoolPool = addr; 47 | } 48 | 49 | /* 50 | * Timer functions 51 | */ 52 | 53 | /// @notice Allows to set timer contract address and init timer. 54 | /// @param timer Address of a timer contract. 55 | /// Can be called only by off-chain app with owner keys. 56 | function initTimer(address timer, uint period) public acceptOnlyOwner { 57 | m_timer = timer; 58 | m_timeout = period; 59 | _settimer(timer, period); 60 | } 61 | 62 | /// @notice Allows to init timer sending request to Timer contract. 63 | /// @param timer Address of a timer contract. 64 | function _settimer(address timer, uint period) private inline { 65 | uint opex = period * _timerRate + _fwdFee * 8 + _epsilon; 66 | ITimer(timer).setTimer.value(opex)(period); 67 | } 68 | 69 | /// @notice Timer callback function. 70 | function onTimer() public { 71 | address timer = m_timer; 72 | uint period = m_timeout; 73 | if (msg.sender == timer && period > 0) { 74 | IDePool(m_dePoolPool).ticktock.value(TICKTOCK_FEE)(); 75 | _settimer(timer, period); 76 | } 77 | } 78 | 79 | /// @notice Allows to send ticktock manually. 80 | /// Can be called only by off-chain app with owner keys. 81 | function sendTicktock() public acceptOnlyOwner { 82 | IDePool(m_dePoolPool).ticktock.value(TICKTOCK_FEE)(); 83 | } 84 | 85 | /* 86 | get methods 87 | */ 88 | 89 | function getDePoolPoolAddress() public view returns (address addr) { 90 | addr = m_dePoolPool; 91 | } 92 | 93 | function getHistory() public view returns (address[] list) { 94 | list = m_poolHistory; 95 | } 96 | 97 | /* 98 | * Set code 99 | */ 100 | 101 | function upgrade(TvmCell newcode) public acceptOnlyOwner { 102 | tvm.commit(); 103 | tvm.setcode(newcode); 104 | tvm.setCurrentCode(newcode); 105 | onCodeUpgrade(); 106 | } 107 | 108 | function onCodeUpgrade() private {} 109 | 110 | receive() external override {} 111 | fallback() external override {} 112 | } 113 | -------------------------------------------------------------------------------- /solidity/depool/DePoolHelper.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depool/DePoolHelper.tvc -------------------------------------------------------------------------------- /solidity/depool/DePoolProxy.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | ], 9 | "outputs": [ 10 | ] 11 | }, 12 | { 13 | "name": "process_new_stake", 14 | "inputs": [ 15 | {"name":"queryId","type":"uint64"}, 16 | {"name":"validatorKey","type":"uint256"}, 17 | {"name":"stakeAt","type":"uint32"}, 18 | {"name":"maxFactor","type":"uint32"}, 19 | {"name":"adnlAddr","type":"uint256"}, 20 | {"name":"signature","type":"bytes"}, 21 | {"name":"elector","type":"address"} 22 | ], 23 | "outputs": [ 24 | ] 25 | }, 26 | { 27 | "name": "onStakeAccept", 28 | "id": "0xF374484C", 29 | "inputs": [ 30 | {"name":"queryId","type":"uint64"}, 31 | {"name":"comment","type":"uint32"} 32 | ], 33 | "outputs": [ 34 | ] 35 | }, 36 | { 37 | "name": "onStakeReject", 38 | "id": "0xEE6F454C", 39 | "inputs": [ 40 | {"name":"queryId","type":"uint64"}, 41 | {"name":"comment","type":"uint32"} 42 | ], 43 | "outputs": [ 44 | ] 45 | }, 46 | { 47 | "name": "recover_stake", 48 | "inputs": [ 49 | {"name":"queryId","type":"uint64"}, 50 | {"name":"elector","type":"address"} 51 | ], 52 | "outputs": [ 53 | ] 54 | }, 55 | { 56 | "name": "onSuccessToRecoverStake", 57 | "id": "0xF96F7324", 58 | "inputs": [ 59 | {"name":"queryId","type":"uint64"} 60 | ], 61 | "outputs": [ 62 | ] 63 | }, 64 | { 65 | "name": "withdrawExcessTons", 66 | "inputs": [ 67 | ], 68 | "outputs": [ 69 | ] 70 | }, 71 | { 72 | "name": "getProxyInfo", 73 | "inputs": [ 74 | ], 75 | "outputs": [ 76 | {"name":"depool","type":"address"}, 77 | {"name":"minBalance","type":"uint64"} 78 | ] 79 | } 80 | ], 81 | "data": [ 82 | {"key":1,"name":"m_id","type":"uint8"}, 83 | {"key":2,"name":"m_dePool","type":"address"}, 84 | {"key":3,"name":"m_validatorWallet","type":"address"} 85 | ], 86 | "events": [ 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /solidity/depool/DePoolProxy.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.6.0; 4 | import "IElector.sol"; 5 | import "IDePool.sol"; 6 | import "IProxy.sol"; 7 | import "DePoolLib.sol"; 8 | 9 | contract DePoolProxyContract is IProxy { 10 | 11 | uint constant ERROR_IS_NOT_DEPOOL = 102; 12 | uint constant ERROR_BAD_BALANCE = 103; 13 | uint constant ERROR_IS_NOT_VALIDATOR = 104; 14 | 15 | uint8 static m_id; 16 | address static m_dePool; 17 | address static m_validatorWallet; 18 | 19 | constructor() public { 20 | require(msg.sender == m_dePool, ERROR_IS_NOT_DEPOOL); 21 | } 22 | 23 | modifier onlyDePoolAndCheckBalance { 24 | require(msg.sender == m_dePool, ERROR_IS_NOT_DEPOOL); 25 | 26 | // this check is needed for correct work of proxy 27 | require(address(this).balance >= msg.value + DePoolLib.MIN_PROXY_BALANCE, ERROR_BAD_BALANCE); 28 | _; 29 | } 30 | 31 | /* 32 | * process_new_stake 33 | */ 34 | 35 | /// @dev Allows to send validator request to run in validator elections 36 | function process_new_stake( 37 | uint64 queryId, 38 | uint256 validatorKey, 39 | uint32 stakeAt, 40 | uint32 maxFactor, 41 | uint256 adnlAddr, 42 | bytes signature, 43 | address elector 44 | ) external override onlyDePoolAndCheckBalance { 45 | IElector(elector).process_new_stake{value: msg.value - DePoolLib.PROXY_FEE}( 46 | queryId, validatorKey, stakeAt, maxFactor, adnlAddr, signature 47 | ); 48 | } 49 | 50 | /// @dev Elector answer from process_new_stake in case of success. 51 | function onStakeAccept(uint64 queryId, uint32 comment) public functionID(0xF374484C) view { 52 | // Elector contract always sends 1 ton 53 | IDePool(m_dePool).onStakeAccept{ 54 | value: msg.value - DePoolLib.PROXY_FEE, 55 | bounce: false 56 | }(queryId, comment, msg.sender); 57 | } 58 | 59 | /// @dev Elector answer from process_new_stake in case of error. 60 | function onStakeReject(uint64 queryId, uint32 comment) view public functionID(0xEE6F454C) { 61 | IDePool(m_dePool).onStakeReject{ 62 | value: msg.value - DePoolLib.PROXY_FEE, 63 | bounce: false 64 | }(queryId, comment, msg.sender); 65 | } 66 | 67 | /* 68 | * recover_stake 69 | */ 70 | 71 | /// @dev Allows to recover validator stake 72 | function recover_stake(uint64 queryId, address elector) public override onlyDePoolAndCheckBalance { 73 | IElector(elector).recover_stake{value: msg.value - DePoolLib.PROXY_FEE}(queryId); 74 | } 75 | 76 | /// @dev Elector answer from recover_stake in case of success. 77 | function onSuccessToRecoverStake(uint64 queryId) public view functionID(0xF96F7324) { 78 | IDePool(m_dePool).onSuccessToRecoverStake{ 79 | value: msg.value - DePoolLib.PROXY_FEE, 80 | bounce: false 81 | }(queryId, msg.sender); 82 | } 83 | 84 | fallback() external view { 85 | TvmSlice payload = msg.data; 86 | (uint32 functionId, uint64 queryId) = payload.decode(uint32, uint64); 87 | if (functionId == 0xfffffffe) { 88 | IDePool(m_dePool).onFailToRecoverStake{ 89 | value: msg.value - DePoolLib.PROXY_FEE, 90 | bounce: false 91 | }(queryId, msg.sender); 92 | } 93 | } 94 | 95 | receive() external {} 96 | 97 | function withdrawExcessTons() public view { 98 | require(msg.sender == m_validatorWallet, ERROR_IS_NOT_VALIDATOR); 99 | uint128 balance = address(this).balance; 100 | if (balance >= 2 * DePoolLib.MIN_PROXY_BALANCE) { 101 | uint128 returnValue = balance - 2 * DePoolLib.MIN_PROXY_BALANCE; 102 | m_validatorWallet.transfer({value: returnValue, bounce: false, flag: 0}); 103 | } 104 | } 105 | 106 | /* 107 | * Public Getters 108 | */ 109 | 110 | function getProxyInfo() public view returns (address depool, uint64 minBalance) { 111 | depool = m_dePool; 112 | minBalance = DePoolLib.MIN_PROXY_BALANCE; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /solidity/depool/DePoolProxy.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depool/DePoolProxy.tvc -------------------------------------------------------------------------------- /solidity/depool/IDePool.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.5.0; 4 | 5 | interface IDePool { 6 | function onStakeAccept(uint64 queryId, uint32 comment, address elector) external; 7 | function onStakeReject(uint64 queryId, uint32 comment, address elector) external; 8 | function onSuccessToRecoverStake(uint64 queryId, address elector) external; 9 | function onFailToRecoverStake(uint64 queryId, address elector) external; 10 | function ticktock() external; 11 | } -------------------------------------------------------------------------------- /solidity/depool/IDePoolInfoGetter.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time"], 4 | "functions": [ 5 | { 6 | "name": "receiveDePoolInfo", 7 | "inputs": [ 8 | {"components":[{"name":"supposedElectedAt","type":"uint32"},{"name":"participantRewardFraction","type":"uint8"},{"name":"validatorRewardFraction","type":"uint8"},{"name":"participantQty","type":"uint32"},{"name":"roundStake","type":"uint64"},{"name":"validatorWallet","type":"address"},{"name":"validatorAssurance","type":"uint64"},{"name":"grossReward","type":"uint64"},{"name":"validatorReward","type":"uint64"},{"name":"participantReward","type":"uint64"},{"name":"reason","type":"uint8"},{"name":"isDePoolClosed","type":"bool"}],"name":"lastRoundInfo","type":"tuple"} 9 | ], 10 | "outputs": [ 11 | ] 12 | }, 13 | { 14 | "name": "constructor", 15 | "inputs": [ 16 | ], 17 | "outputs": [ 18 | ] 19 | } 20 | ], 21 | "data": [ 22 | ], 23 | "events": [ 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /solidity/depool/IDePoolInfoGetter.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.6.0; 4 | 5 | import "DePoolRounds.sol"; 6 | 7 | interface IDePoolInfoGetter { 8 | function receiveDePoolInfo(LastRoundInfo lastRoundInfo) external; 9 | } 10 | 11 | contract DePoolInfoGetter is IDePoolInfoGetter { 12 | function receiveDePoolInfo(LastRoundInfo lastRoundInfo) external override {} 13 | } 14 | -------------------------------------------------------------------------------- /solidity/depool/IElector.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.6.0; 4 | 5 | interface IElector { 6 | /// @dev Allows validator to become validator candidate 7 | function process_new_stake( 8 | uint64 queryId, 9 | uint256 validatorKey, 10 | uint32 stakeAt, 11 | uint32 maxFactor, 12 | uint256 adnlAddr, 13 | bytes signature 14 | ) external functionID(0x4E73744B); 15 | 16 | /// @dev Allows to get back validator's stake 17 | function recover_stake(uint64 queryId) external functionID(0x47657424); 18 | } -------------------------------------------------------------------------------- /solidity/depool/IParticipant.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "onRoundComplete", 7 | "inputs": [ 8 | {"name":"roundId","type":"uint64"}, 9 | {"name":"reward","type":"uint64"}, 10 | {"name":"ordinaryStake","type":"uint64"}, 11 | {"name":"vestingStake","type":"uint64"}, 12 | {"name":"lockStake","type":"uint64"}, 13 | {"name":"reinvest","type":"bool"}, 14 | {"name":"reason","type":"uint8"} 15 | ], 16 | "outputs": [ 17 | ] 18 | }, 19 | { 20 | "name": "receiveAnswer", 21 | "inputs": [ 22 | {"name":"errcode","type":"uint32"}, 23 | {"name":"comment","type":"uint64"} 24 | ], 25 | "outputs": [ 26 | ] 27 | }, 28 | { 29 | "name": "onTransfer", 30 | "inputs": [ 31 | {"name":"source","type":"address"}, 32 | {"name":"amount","type":"uint128"} 33 | ], 34 | "outputs": [ 35 | ] 36 | }, 37 | { 38 | "name": "constructor", 39 | "inputs": [ 40 | ], 41 | "outputs": [ 42 | ] 43 | } 44 | ], 45 | "data": [ 46 | ], 47 | "events": [ 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /solidity/depool/IParticipant.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.6.0; 4 | pragma AbiHeader expire; 5 | pragma AbiHeader time; 6 | 7 | interface IParticipant { 8 | /// @dev send a notification from DePool to Participant when round is completed 9 | /// @param roundId Id of completed round. 10 | /// @param reward Participant's reward in completed round in nanotons. 11 | /// @param ordinaryStake Ordinary stake in completed round. 12 | /// @param vestingStake Vesting stake in completed round. 13 | /// @param lockStake Lock stake in completed round. 14 | /// @param reinvest Is ordinary stake automatically reinvested (prolonged)? 15 | /// @param reason Reason why round is completed (See enum CompletionReason). 16 | function onRoundComplete( 17 | uint64 roundId, 18 | uint64 reward, 19 | uint64 ordinaryStake, 20 | uint64 vestingStake, 21 | uint64 lockStake, 22 | bool reinvest, 23 | uint8 reason) external; 24 | 25 | /// @dev Send a message with status code and certain value to participant as a result of DePool operation. 26 | /// @param errcode Error code of operation. 27 | /// @param comment Additional value for certain error code. 28 | function receiveAnswer(uint32 errcode, uint64 comment) external; 29 | 30 | function onTransfer(address source, uint128 amount) external; 31 | } 32 | 33 | 34 | contract ParticipantContract is IParticipant { 35 | function onRoundComplete( 36 | uint64 roundId, 37 | uint64 reward, 38 | uint64 ordinaryStake, 39 | uint64 vestingStake, 40 | uint64 lockStake, 41 | bool reinvest, 42 | uint8 reason) external override 43 | { 44 | 45 | } 46 | 47 | function receiveAnswer(uint32 errcode, uint64 comment) external override { 48 | 49 | } 50 | 51 | function onTransfer(address source, uint128 amount) external override { 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /solidity/depool/IProxy.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >=0.5.0; 4 | 5 | interface IProxy { 6 | function process_new_stake( 7 | uint64 queryId, 8 | uint256 validatorKey, 9 | uint32 stakeAt, 10 | uint32 maxFactor, 11 | uint256 adnlAddr, 12 | bytes signature, 13 | address elector 14 | ) external; 15 | 16 | function recover_stake(uint64 queryId, address elector) external; 17 | } -------------------------------------------------------------------------------- /solidity/depool/Participant.sol: -------------------------------------------------------------------------------- 1 | // 2020 (c) TON Venture Studio Ltd 2 | 3 | pragma solidity >0.6.0; 4 | pragma AbiHeader expire; 5 | pragma AbiHeader time; 6 | 7 | import "DePoolLib.sol"; 8 | 9 | contract ParticipantContract { 10 | function sendTransaction( 11 | address dest, 12 | uint64 value, 13 | bool bounce, 14 | uint16 flags, 15 | TvmCell payload) public view 16 | { 17 | require(msg.pubkey() == tvm.pubkey(), Errors.IS_NOT_OWNER); 18 | tvm.accept(); 19 | dest.transfer(value, bounce, flags, payload); 20 | } 21 | 22 | receive() external virtual {} 23 | fallback() external virtual {} 24 | } -------------------------------------------------------------------------------- /solidity/depress/DePress/DePress.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"keymembers","type":"map(uint256,bool)"}, 9 | {"name":"owner","type":"uint256"} 10 | ], 11 | "outputs": [ 12 | ] 13 | }, 14 | { 15 | "name": "setText", 16 | "inputs": [ 17 | {"name":"text","type":"bytes"}, 18 | {"name":"nonce","type":"uint32"} 19 | ], 20 | "outputs": [ 21 | ] 22 | }, 23 | { 24 | "name": "addPublication", 25 | "inputs": [ 26 | {"name":"pub","type":"bytes"}, 27 | {"name":"nonce","type":"uint32"} 28 | ], 29 | "outputs": [ 30 | ] 31 | }, 32 | { 33 | "name": "sign", 34 | "inputs": [ 35 | ], 36 | "outputs": [ 37 | ] 38 | }, 39 | { 40 | "name": "setEncryptionKey", 41 | "inputs": [ 42 | {"name":"key","type":"uint256"} 43 | ], 44 | "outputs": [ 45 | ] 46 | }, 47 | { 48 | "name": "getInfo", 49 | "inputs": [ 50 | ], 51 | "outputs": [ 52 | {"name":"text","type":"bytes"}, 53 | {"name":"publications","type":"bytes[]"}, 54 | {"name":"signkey","type":"uint256"}, 55 | {"name":"enckey","type":"uint256"}, 56 | {"name":"nonce","type":"uint32"} 57 | ] 58 | }, 59 | { 60 | "name": "getKeyMembers", 61 | "inputs": [ 62 | ], 63 | "outputs": [ 64 | {"name":"pubkeys","type":"map(uint256,bool)"} 65 | ] 66 | }, 67 | { 68 | "name": "transfer", 69 | "inputs": [ 70 | {"name":"dest","type":"address"}, 71 | {"name":"value","type":"uint128"}, 72 | {"name":"bounce","type":"bool"}, 73 | {"name":"flags","type":"uint16"} 74 | ], 75 | "outputs": [ 76 | ] 77 | } 78 | ], 79 | "data": [ 80 | ], 81 | "events": [ 82 | ] 83 | } 84 | -------------------------------------------------------------------------------- /solidity/depress/DePress/DePress.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >= 0.6.0; 2 | pragma AbiHeader expire; 3 | pragma AbiHeader time; 4 | pragma AbiHeader pubkey; 5 | 6 | contract DePress { 7 | 8 | bytes m_text; 9 | bytes[] m_publications; 10 | mapping(uint256 => bool) m_keymembers; 11 | uint256 m_signkey; 12 | uint256 m_enckey; 13 | uint32 m_nonce; 14 | uint256 m_owner; 15 | 16 | //errors 17 | // 101 - wrong owner keys 18 | // 102 - no key member list 19 | // 103 - already sign by key member 20 | // 104 - not valid key member 21 | // 105 - there is no any publication 22 | // 106 - encryption key is already set 23 | // 108 - no sign from key member 24 | // 111 - text is empty 25 | // 112 - wrong nonce. dublicated nonce. 26 | 27 | 28 | constructor(mapping(uint256 => bool) keymembers, uint256 owner) public { 29 | require(msg.pubkey() == tvm.pubkey(), 101); 30 | require(!keymembers.empty(), 102); 31 | tvm.accept(); 32 | m_keymembers = keymembers; 33 | m_owner = owner; 34 | } 35 | 36 | function setText(bytes text, uint32 nonce) public { 37 | require(m_owner == msg.pubkey(), 101); 38 | require(m_signkey == 0, 103); 39 | require(nonce==(m_nonce+1),112); 40 | tvm.accept(); 41 | m_text = text; 42 | m_nonce = nonce; 43 | } 44 | 45 | function addPublication(bytes pub, uint32 nonce) public { 46 | require(m_owner == msg.pubkey(), 101); 47 | require(m_signkey != 0, 108); 48 | require(m_enckey == 0, 106); 49 | require(nonce==(m_nonce+m_publications.length+1),112); 50 | tvm.accept(); 51 | m_publications.push(pub); 52 | } 53 | 54 | function sign() public { 55 | require(m_keymembers.exists(msg.pubkey()), 104); 56 | require(m_signkey == 0, 103); 57 | require(m_text.length > 0, 111); 58 | tvm.accept(); 59 | m_signkey = msg.pubkey(); 60 | } 61 | 62 | function setEncryptionKey(uint256 key) public { 63 | require(m_owner == msg.pubkey(), 101); 64 | require(m_publications.length > 0, 105); 65 | tvm.accept(); 66 | m_enckey = key; 67 | } 68 | 69 | function getInfo() public view returns(bytes text, bytes[] publications, uint256 signkey, uint256 enckey, uint32 nonce) 70 | { 71 | text = m_text; 72 | publications = m_publications; 73 | signkey = m_signkey; 74 | enckey = m_enckey; 75 | nonce = m_nonce; 76 | } 77 | 78 | function getKeyMembers() public view returns(mapping(uint256 => bool) pubkeys){ 79 | pubkeys = m_keymembers; 80 | } 81 | 82 | function transfer(address dest, uint128 value, bool bounce, uint16 flags) public view { 83 | require(m_owner == msg.pubkey(), 101); 84 | tvm.accept(); 85 | dest.transfer(value, bounce, flags); 86 | } 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /solidity/depress/DePress/DePress.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depress/DePress/DePress.tvc -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/DePressDeBot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depress/DePressDeBot/DePressDeBot.tvc -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/DePress_tvc.txt: -------------------------------------------------------------------------------- 1 | te6ccgECIgEABecAAgE0AwEBAcACAEPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAib/APSkICLAAZL0oOGK7VNYMPShCAQBCvSkIPShBQIJnwAAAAkHBgBrO1E0NP/0z/TANXXC//4cNTTH/QEWW8C+Gv0BNP/0//XCx/4b/hu+G34bPhqf/hh+Gb4Y/higAG8+ELIy//4Q88LP/hGzwsAyPhQAcv/+Er4S28i+Ez4TfhO+E9ecM8RzMsf9AD0AMv/y//LH8ntVIAIBIAwJAcr/f40IYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABPhpIe1E0CDXScIBjjLT/9M/0wDV1wv/+HDU0x/0BFlvAvhr9ATT/9P/1wsf+G/4bvht+Gz4an/4Yfhm+GP4YgoB/o4x9AXIyfhqcG1vAvhrbfhscPhtcPhucPhvcPhwcAGAQPQO8r3XC//4YnD4Y3D4Zn/4YeLTAAGOHYECANcYIPkBAdMAAZTT/wMBkwL4QuIg+GX5EPKoldMAAfJ64tM/AY4d+EMhuSCfMCD4I4ED6KiCCBt3QKC53pL4Y+Aw8jQLAE7Y0x8B+CO88rnTHyHBAyKCEP////28sZNb8jzgAfAB+EdukzDyPN4CASAZDQIBIBgOAgEgEA8AcbhFOoH/CC3SXgE72uG/8rqaOhp/+/o/Ch8IpA3SRg4b115cDL8JbeIYQB5cDT8ABB8Nxh4BD/8M8AIBWBMRAde0xQJL/CC3SXgE7xDM6Y/8Iiw3uvwyb+jkZLg2t4E4ODh8JRr8JZp8Jpn8Jxl8J5iS4H/HGxPoaYD9IBgY5GfDkGdAMGegZ8DnwOfJ2xQJLxLnihI3kQFlj/oAEeeF/5Fnhf+Q54WP5Lj9gEASALCOTPhEIG8TIW8S+ElVAm8RyHLPQMoAc89AzgH6AvQAgGjPQM+Bz4PI+ERvFc8LHybPFCVvIgLLH/QAJM8L/yPPC/8izwsfzcn4RG8U+wDiXwWS8Ajef/hnAgFmFRQAi65WptfhBbpLwCd7R+EUgbpIwcN74TIEBAPQOIJEx3vLgaPhNwADy4Gf4StDXSasCwgDy4G/4APhFIG6SMHDe+G3wCH/4Z4BB64GZbYWAf74QW6S8AneIZnTH/hEWG91+GTf0W34TDEhwP+OIyPQ0wH6QDAxyM+HIM6AYM9Az4HPgc+TpAZltiEB9ADJcfsAjjf4RCBvEyFvEvhJVQJvEchyz0DKAHPPQM4B+gL0AIBoz0DPgc+B+ERvFc8LHyEB9ADJ+ERvFPsA4jCS8AjeFwAGf/hnAKu664SY74QW6S8Ane1NMf0fhQ+EUgbpIwcN668uBl+E3DAPLgbPhOwADy4Gog+E/4S28QoHGgtf+68uBw+AD4SyIBbyIhpANZgCD0F28C+Gtb8Ah/+GeAIBSB8aAgFYHBsA0bSM7UL8ILdJeATvfSDK6mjofSBv64a/yupo6Gm/7+uGAErqaOhpAG/rhofK6mjoaYfv6PwofCKQN0kYOG9deXAy/AAREhHkZ8LAZQA556BnAP0BQDTnoGfA58DkkP2AL4JJeARvP/wzwAEJtahh4cAdAf74QW6OcO1E0CDXScIBjjLT/9M/0wDV1wv/+HDU0x/0BFlvAvhr9ATT/9P/1wsf+G/4bvht+Gz4an/4Yfhm+GP4Yo4x9AXIyfhqcG1vAvhrbfhscPhtcPhucPhvcPhwcAGAQPQO8r3XC//4YnD4Y3D4Zn/4YeLe+Ebyc3H4ZvQEHgBa1w3/ldTR0NP/39H4RSBukjBw3vhCuvLgZSFus/LgZvgAIfhsIPhwW/AIf/hnAgFIISAAe7Uz0HF8ILdJeATvammP6PwofCKQN0kYOG9deXAy/CbgAHlwM5B8J7jQWo/deXA4fAAQ/DUQfDet+AQ//DPAAJDacCLQ0wP6QDD4aak4APhEf29xggiYloBvcm1vc3FvdPhk3CHHANwh0x8h3SHBAyKCEP////28sZNb8jzgAfAB+EdukzDyPN4= 2 | -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/Transferable.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | abstract contract Transferable { 4 | function transfer(address dest, uint128 value, bool bounce, uint16 flags) public view { 5 | require(msg.pubkey() == tvm.pubkey(), 100); 6 | tvm.accept(); 7 | dest.transfer(value, bounce, flags); 8 | } 9 | } -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/Upgradable.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | abstract contract Upgradable { 4 | /* 5 | * Set code 6 | */ 7 | 8 | function upgrade(TvmCell state) public virtual { 9 | require(msg.pubkey() == tvm.pubkey(), 100); 10 | TvmCell newcode = state.toSlice().loadRef(); 11 | tvm.accept(); 12 | tvm.commit(); 13 | tvm.setcode(newcode); 14 | tvm.setCurrentCode(newcode); 15 | onCodeUpgrade(); 16 | } 17 | 18 | function onCodeUpgrade() internal virtual; 19 | } -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=DePressDeBot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | CLI_PATH=~/git/tonos-cli/target/release 10 | LOCAL_GIVER_PATH=~/givers/local_giver 11 | NET_GIVER_PATH=~/givers/net_giver 12 | DEPLOY_LOCAL=1 13 | 14 | function giver_local { 15 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":5000000000}" 16 | } 17 | function giver_net { 18 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 19 | } 20 | function get_address { 21 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 22 | } 23 | 24 | echo "" 25 | echo "[DePress DEBOT]" 26 | echo "" 27 | 28 | echo GENADDR DEBOT 29 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 30 | debot_address=$(get_address) 31 | echo GIVER 32 | if [ "$DEPLOY_LOCAL" = "" ]; then 33 | giver_net $debot_address 34 | else 35 | giver_local $debot_address 36 | fi 37 | echo DEPLOY DEBOT 38 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 39 | $CLI_PATH/tonos-cli deploy $filenametvc "{}" --sign $filenamekeys --abi $filenameabi 40 | echo SET DEBOT ABI 41 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 42 | echo SET CODE 43 | depool_tvc=$(cat DePress_tvc.txt) 44 | $CLI_PATH/tonos-cli call $debot_address setDePressCode "{\"code\":\"$depool_tvc\"}" --sign $filenamekeys --abi $filenameabi 45 | 46 | echo DONE 47 | echo $debot_address > address.log 48 | 49 | -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/itf/Base64.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface IBase64 { 4 | 5 | function encode(uint32 answerId, bytes data) external returns (string base64); 6 | function decode(uint32 answerId, string base64) external returns (bytes data); 7 | 8 | } 9 | 10 | library Base64 { 11 | 12 | uint256 constant ITF_ADDR = 0x8913b27b45267aad3ee08437e64029ac38fb59274f19adca0b23c4f957c8cfa1; 13 | int8 constant DEBOT_WC = -31; 14 | 15 | function encode(uint32 answerId, bytes data) public pure { 16 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 17 | IBase64(addr).encode(answerId, data); 18 | } 19 | 20 | function decode(uint32 answerId, string base64) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 22 | IBase64(addr).decode(answerId, base64); 23 | } 24 | 25 | } 26 | 27 | contract Base64ABI is IBase64 { 28 | 29 | function encode(uint32 answerId, bytes data) external override returns (string base64) {} 30 | function decode(uint32 answerId, string base64) external override returns (bytes data) {} 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/itf/Menu.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | struct MenuItem { 4 | string title; 5 | string description; 6 | uint32 handlerId; 7 | } 8 | 9 | interface IMenu { 10 | 11 | function select(string title, string description, MenuItem[] items) external returns (uint32 index); 12 | 13 | } 14 | 15 | library Menu { 16 | 17 | uint256 constant ID = 0xac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function select(string title, string description, MenuItem[] items) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | IMenu(addr).select(title, description, items); 23 | } 24 | } 25 | 26 | contract MenuABI is IMenu { 27 | 28 | function select(string title, string description, MenuItem[] items) external override returns (uint32 index) {} 29 | 30 | } -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/itf/Msg.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface IMsg { 4 | 5 | function sendWithKeypair(uint32 answerId, TvmCell message, uint256 pub, uint256 sec) external; 6 | 7 | } 8 | 9 | library Msg { 10 | 11 | uint256 constant ID_MSG = 0x475a5d1729acee4601c2a8cb67240e4da5316cc90a116e1b181d905e79401c51; 12 | int8 constant DEBOT_WC = -31; 13 | 14 | function sendWithKeypair(uint32 answerId, TvmCell message, uint256 pub, uint256 sec) public pure { 15 | address addr = address.makeAddrStd(DEBOT_WC, ID_MSG); 16 | IMsg(addr).sendWithKeypair(answerId, message, pub, sec); 17 | } 18 | 19 | } 20 | 21 | contract MsgABI is IMsg { 22 | function sendWithKeypair(uint32 answerId, TvmCell message, uint256 pub, uint256 sec) external override {} 23 | } -------------------------------------------------------------------------------- /solidity/depress/DePressDeBot/itf/Terminal.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface ITerminal { 4 | 5 | function inputStr(uint32 answerId, string prompt, bool multiline) external returns (string value); 6 | function inputInt (uint32 answerId, string prompt) external returns (int256 value); 7 | function inputUint(uint32 answerId, string prompt) external returns (uint256 value); 8 | function inputTons(uint32 answerId, string prompt) external returns (uint128 value); 9 | function inputBoolean(uint32 answerId, string prompt) external returns (bool value); 10 | function print(uint32 answerId, string message) external; 11 | function printf(uint32 answerId, string fmt, TvmCell fargs) external; 12 | 13 | } 14 | 15 | library Terminal { 16 | 17 | uint256 constant ID = 0x8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function inputStr(uint32 answerId, string prompt, bool multiline) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | ITerminal(addr).inputStr(answerId, prompt, multiline); 23 | } 24 | function inputInt(uint32 answerId, string prompt) public pure { 25 | address addr = address.makeAddrStd(DEBOT_WC, ID); 26 | ITerminal(addr).inputInt(answerId, prompt); 27 | } 28 | function inputUint(uint32 answerId, string prompt) public pure { 29 | address addr = address.makeAddrStd(DEBOT_WC, ID); 30 | ITerminal(addr).inputUint(answerId, prompt); 31 | } 32 | function inputTons(uint32 answerId, string prompt) public pure { 33 | address addr = address.makeAddrStd(DEBOT_WC, ID); 34 | ITerminal(addr).inputTons(answerId, prompt); 35 | } 36 | function inputBoolean(uint32 answerId, string prompt) public pure { 37 | address addr = address.makeAddrStd(DEBOT_WC, ID); 38 | ITerminal(addr).inputBoolean(answerId, prompt); 39 | } 40 | function print(uint32 answerId, string message) public pure { 41 | address addr = address.makeAddrStd(DEBOT_WC, ID); 42 | ITerminal(addr).print(answerId, message); 43 | } 44 | function printf(uint32 answerId, string fmt, TvmCell fargs) public pure { 45 | address addr = address.makeAddrStd(DEBOT_WC, ID); 46 | ITerminal(addr).printf(answerId, fmt, fargs); 47 | } 48 | } 49 | 50 | contract TerminalABI is ITerminal { 51 | 52 | function inputStr(uint32 answerId, string prompt, bool multiline) external override returns (string value) {} 53 | function inputInt (uint32 answerId, string prompt) external override returns (int256 value) {} 54 | function inputUint(uint32 answerId, string prompt) external override returns (uint256 value) {} 55 | function inputTons(uint32 answerId, string prompt) external override returns (uint128 value) {} 56 | function inputBoolean(uint32 answerId, string prompt) external override returns (bool value) {} 57 | function print(uint32 answerId, string message) external override {} 58 | function printf(uint32 answerId, string fmt, TvmCell fargs) external override {} 59 | 60 | } -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/DePressMemberDeBot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/depress/DePressMemberDeBot/DePressMemberDeBot.tvc -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/DePress_tvc.txt: -------------------------------------------------------------------------------- 1 | te6ccgECIgEABecAAgE0AwEBAcACAEPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAib/APSkICLAAZL0oOGK7VNYMPShCAQBCvSkIPShBQIJnwAAAAkHBgBrO1E0NP/0z/TANXXC//4cNTTH/QEWW8C+Gv0BNP/0//XCx/4b/hu+G34bPhqf/hh+Gb4Y/higAG8+ELIy//4Q88LP/hGzwsAyPhQAcv/+Er4S28i+Ez4TfhO+E9ecM8RzMsf9AD0AMv/y//LH8ntVIAIBIAwJAcr/f40IYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABPhpIe1E0CDXScIBjjLT/9M/0wDV1wv/+HDU0x/0BFlvAvhr9ATT/9P/1wsf+G/4bvht+Gz4an/4Yfhm+GP4YgoB/o4x9AXIyfhqcG1vAvhrbfhscPhtcPhucPhvcPhwcAGAQPQO8r3XC//4YnD4Y3D4Zn/4YeLTAAGOHYECANcYIPkBAdMAAZTT/wMBkwL4QuIg+GX5EPKoldMAAfJ64tM/AY4d+EMhuSCfMCD4I4ED6KiCCBt3QKC53pL4Y+Aw8jQLAE7Y0x8B+CO88rnTHyHBAyKCEP////28sZNb8jzgAfAB+EdukzDyPN4CASAZDQIBIBgOAgEgEA8AcbhFOoH/CC3SXgE72uG/8rqaOhp/+/o/Ch8IpA3SRg4b115cDL8JbeIYQB5cDT8ABB8Nxh4BD/8M8AIBWBMRAde0xQJL/CC3SXgE7xDM6Y/8Iiw3uvwyb+jkZLg2t4E4ODh8JRr8JZp8Jpn8Jxl8J5iS4H/HGxPoaYD9IBgY5GfDkGdAMGegZ8DnwOfJ2xQJLxLnihI3kQFlj/oAEeeF/5Fnhf+Q54WP5Lj9gEASALCOTPhEIG8TIW8S+ElVAm8RyHLPQMoAc89AzgH6AvQAgGjPQM+Bz4PI+ERvFc8LHybPFCVvIgLLH/QAJM8L/yPPC/8izwsfzcn4RG8U+wDiXwWS8Ajef/hnAgFmFRQAi65WptfhBbpLwCd7R+EUgbpIwcN74TIEBAPQOIJEx3vLgaPhNwADy4Gf4StDXSasCwgDy4G/4APhFIG6SMHDe+G3wCH/4Z4BB64GZbYWAf74QW6S8AneIZnTH/hEWG91+GTf0W34TDEhwP+OIyPQ0wH6QDAxyM+HIM6AYM9Az4HPgc+TpAZltiEB9ADJcfsAjjf4RCBvEyFvEvhJVQJvEchyz0DKAHPPQM4B+gL0AIBoz0DPgc+B+ERvFc8LHyEB9ADJ+ERvFPsA4jCS8AjeFwAGf/hnAKu664SY74QW6S8Ane1NMf0fhQ+EUgbpIwcN668uBl+E3DAPLgbPhOwADy4Gog+E/4S28QoHGgtf+68uBw+AD4SyIBbyIhpANZgCD0F28C+Gtb8Ah/+GeAIBSB8aAgFYHBsA0bSM7UL8ILdJeATvfSDK6mjofSBv64a/yupo6Gm/7+uGAErqaOhpAG/rhofK6mjoaYfv6PwofCKQN0kYOG9deXAy/AAREhHkZ8LAZQA556BnAP0BQDTnoGfA58DkkP2AL4JJeARvP/wzwAEJtahh4cAdAf74QW6OcO1E0CDXScIBjjLT/9M/0wDV1wv/+HDU0x/0BFlvAvhr9ATT/9P/1wsf+G/4bvht+Gz4an/4Yfhm+GP4Yo4x9AXIyfhqcG1vAvhrbfhscPhtcPhucPhvcPhwcAGAQPQO8r3XC//4YnD4Y3D4Zn/4YeLe+Ebyc3H4ZvQEHgBa1w3/ldTR0NP/39H4RSBukjBw3vhCuvLgZSFus/LgZvgAIfhsIPhwW/AIf/hnAgFIISAAe7Uz0HF8ILdJeATvammP6PwofCKQN0kYOG9deXAy/CbgAHlwM5B8J7jQWo/deXA4fAAQ/DUQfDet+AQ//DPAAJDacCLQ0wP6QDD4aak4APhEf29xggiYloBvcm1vc3FvdPhk3CHHANwh0x8h3SHBAyKCEP////28sZNb8jzgAfAB+EdukzDyPN4= 2 | -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/Transferable.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | abstract contract Transferable { 4 | function transfer(address dest, uint128 value, bool bounce, uint16 flags) public view { 5 | require(msg.pubkey() == tvm.pubkey(), 100); 6 | tvm.accept(); 7 | dest.transfer(value, bounce, flags); 8 | } 9 | } -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/Upgradable.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | abstract contract Upgradable { 4 | /* 5 | * Set code 6 | */ 7 | 8 | function upgrade(TvmCell state) public virtual { 9 | require(msg.pubkey() == tvm.pubkey(), 100); 10 | TvmCell newcode = state.toSlice().loadRef(); 11 | tvm.accept(); 12 | tvm.commit(); 13 | tvm.setcode(newcode); 14 | tvm.setCurrentCode(newcode); 15 | onCodeUpgrade(); 16 | } 17 | 18 | function onCodeUpgrade() internal virtual; 19 | } -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | filename=DePressMemberDeBot 4 | filenamesol=$filename.sol 5 | filenameabi=$filename.abi.json 6 | filenametvc=$filename.tvc 7 | filenamekeys=$filename.keys.json 8 | 9 | CLI_PATH=~/git/tonos-cli/target/release 10 | LOCAL_GIVER_PATH=~/givers/local_giver 11 | NET_GIVER_PATH=~/givers/net_giver 12 | DEPLOY_LOCAL=1 13 | 14 | function giver_local { 15 | $CLI_PATH/tonos-cli call --abi $LOCAL_GIVER_PATH/giver.abi.json 0:841288ed3b55d9cdafa806807f02a0ae0c169aa5edfe88a789a6482429756a94 sendGrams "{\"dest\":\"$1\",\"amount\":5000000000}" 16 | } 17 | function giver_net { 18 | $CLI_PATH/tonos-cli call 0:2bb4a0e8391e7ea8877f4825064924bd41ce110fce97e939d3323999e1efbb13 sendTransaction "{\"dest\":\"$1\",\"value\":2000000000,\"bounce\":\"false\"}" --abi $NET_GIVER_PATH/giver.abi.json --sign $NET_GIVER_PATH/keys.json 19 | } 20 | function get_address { 21 | echo $(cat log.log | grep "Raw address:" | cut -d ' ' -f 3) 22 | } 23 | 24 | echo "" 25 | echo "[DEPRESS MEMBER DEBOT]" 26 | echo "" 27 | 28 | echo GENADDR DEBOT 29 | $CLI_PATH/tonos-cli genaddr $filenametvc $filenameabi --genkey $filenamekeys > log.log 30 | debot_address=$(get_address) 31 | echo GIVER 32 | if [ "$DEPLOY_LOCAL" = "" ]; then 33 | giver_net $debot_address 34 | else 35 | giver_local $debot_address 36 | fi 37 | echo DEPLOY DEBOT 38 | debot_abi=$(cat $filenameabi | xxd -ps -c 20000) 39 | $CLI_PATH/tonos-cli deploy $filenametvc "{}" --sign $filenamekeys --abi $filenameabi 40 | echo SET DEBOT ABI 41 | $CLI_PATH/tonos-cli call $debot_address setABI "{\"dabi\":\"$debot_abi\"}" --sign $filenamekeys --abi $filenameabi 42 | echo SET CODE 43 | depool_tvc=$(cat DePress_tvc.txt) 44 | $CLI_PATH/tonos-cli call $debot_address setDePressCode "{\"code\":\"$depool_tvc\"}" --sign $filenamekeys --abi $filenameabi 45 | 46 | echo DONE 47 | echo $debot_address > address.log 48 | 49 | -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/itf/AddressInput.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface IAddressInput { 4 | function select(uint32 answerId) external returns (address value); 5 | } 6 | 7 | library AddressInput { 8 | int8 constant DEBOT_WC = -31; 9 | uint256 constant ID = 0xd7ed1bd8e6230871116f4522e58df0a93c5520c56f4ade23ef3d8919a984653b; 10 | 11 | function select(uint32 answerId) public pure { 12 | address addr = address.makeAddrStd(DEBOT_WC, ID); 13 | IAddressInput(addr).select(answerId); 14 | } 15 | } 16 | 17 | contract AddressInputABI is IAddressInput { 18 | function select(uint32 answerId) external override returns (address value) {} 19 | } -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/itf/Base64.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface IBase64 { 4 | 5 | function encode(uint32 answerId, bytes data) external returns (string base64); 6 | function decode(uint32 answerId, string base64) external returns (bytes data); 7 | 8 | } 9 | 10 | library Base64 { 11 | 12 | uint256 constant ITF_ADDR = 0x8913b27b45267aad3ee08437e64029ac38fb59274f19adca0b23c4f957c8cfa1; 13 | int8 constant DEBOT_WC = -31; 14 | 15 | function encode(uint32 answerId, bytes data) public pure { 16 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 17 | IBase64(addr).encode(answerId, data); 18 | } 19 | 20 | function decode(uint32 answerId, string base64) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ITF_ADDR); 22 | IBase64(addr).decode(answerId, base64); 23 | } 24 | 25 | } 26 | 27 | contract Base64ABI is IBase64 { 28 | 29 | function encode(uint32 answerId, bytes data) external override returns (string base64) {} 30 | function decode(uint32 answerId, string base64) external override returns (bytes data) {} 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/itf/Menu.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | struct MenuItem { 4 | string title; 5 | string description; 6 | uint32 handlerId; 7 | } 8 | 9 | interface IMenu { 10 | 11 | function select(string title, string description, MenuItem[] items) external returns (uint32 index); 12 | 13 | } 14 | 15 | library Menu { 16 | 17 | uint256 constant ID = 0xac1a4d3ecea232e49783df4a23a81823cdca3205dc58cd20c4db259c25605b48; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function select(string title, string description, MenuItem[] items) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | IMenu(addr).select(title, description, items); 23 | } 24 | } 25 | 26 | contract MenuABI is IMenu { 27 | 28 | function select(string title, string description, MenuItem[] items) external override returns (uint32 index) {} 29 | 30 | } -------------------------------------------------------------------------------- /solidity/depress/DePressMemberDeBot/itf/Terminal.sol: -------------------------------------------------------------------------------- 1 | pragma ton-solidity ^0.35.0; 2 | 3 | interface ITerminal { 4 | 5 | function inputStr(uint32 answerId, string prompt, bool multiline) external returns (string value); 6 | function inputInt (uint32 answerId, string prompt) external returns (int256 value); 7 | function inputUint(uint32 answerId, string prompt) external returns (uint256 value); 8 | function inputTons(uint32 answerId, string prompt) external returns (uint128 value); 9 | function inputBoolean(uint32 answerId, string prompt) external returns (bool value); 10 | function print(uint32 answerId, string message) external; 11 | function printf(uint32 answerId, string fmt, TvmCell fargs) external; 12 | 13 | } 14 | 15 | library Terminal { 16 | 17 | uint256 constant ID = 0x8796536366ee21852db56dccb60bc564598b618c865fc50c8b1ab740bba128e3; 18 | int8 constant DEBOT_WC = -31; 19 | 20 | function inputStr(uint32 answerId, string prompt, bool multiline) public pure { 21 | address addr = address.makeAddrStd(DEBOT_WC, ID); 22 | ITerminal(addr).inputStr(answerId, prompt, multiline); 23 | } 24 | function inputInt(uint32 answerId, string prompt) public pure { 25 | address addr = address.makeAddrStd(DEBOT_WC, ID); 26 | ITerminal(addr).inputInt(answerId, prompt); 27 | } 28 | function inputUint(uint32 answerId, string prompt) public pure { 29 | address addr = address.makeAddrStd(DEBOT_WC, ID); 30 | ITerminal(addr).inputUint(answerId, prompt); 31 | } 32 | function inputTons(uint32 answerId, string prompt) public pure { 33 | address addr = address.makeAddrStd(DEBOT_WC, ID); 34 | ITerminal(addr).inputTons(answerId, prompt); 35 | } 36 | function inputBoolean(uint32 answerId, string prompt) public pure { 37 | address addr = address.makeAddrStd(DEBOT_WC, ID); 38 | ITerminal(addr).inputBoolean(answerId, prompt); 39 | } 40 | function print(uint32 answerId, string message) public pure { 41 | address addr = address.makeAddrStd(DEBOT_WC, ID); 42 | ITerminal(addr).print(answerId, message); 43 | } 44 | function printf(uint32 answerId, string fmt, TvmCell fargs) public pure { 45 | address addr = address.makeAddrStd(DEBOT_WC, ID); 46 | ITerminal(addr).printf(answerId, fmt, fargs); 47 | } 48 | } 49 | 50 | contract TerminalABI is ITerminal { 51 | 52 | function inputStr(uint32 answerId, string prompt, bool multiline) external override returns (string value) {} 53 | function inputInt (uint32 answerId, string prompt) external override returns (int256 value) {} 54 | function inputUint(uint32 answerId, string prompt) external override returns (uint256 value) {} 55 | function inputTons(uint32 answerId, string prompt) external override returns (uint128 value) {} 56 | function inputBoolean(uint32 answerId, string prompt) external override returns (bool value) {} 57 | function print(uint32 answerId, string message) external override {} 58 | function printf(uint32 answerId, string fmt, TvmCell fargs) external override {} 59 | 60 | } -------------------------------------------------------------------------------- /solidity/dod/dod.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"debotAddr","type":"address"} 9 | ], 10 | "outputs": [ 11 | ] 12 | }, 13 | { 14 | "name": "sign", 15 | "inputs": [ 16 | ], 17 | "outputs": [ 18 | ] 19 | }, 20 | { 21 | "name": "declaration", 22 | "inputs": [ 23 | ], 24 | "outputs": [ 25 | {"name":"declaration","type":"bytes"} 26 | ] 27 | }, 28 | { 29 | "name": "signatures", 30 | "inputs": [ 31 | ], 32 | "outputs": [ 33 | {"name":"signatures","type":"uint64"} 34 | ] 35 | }, 36 | { 37 | "name": "debot", 38 | "inputs": [ 39 | ], 40 | "outputs": [ 41 | {"name":"debot","type":"address"} 42 | ] 43 | } 44 | ], 45 | "data": [ 46 | ], 47 | "events": [ 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /solidity/dod/dod.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/dod/dod.tvc -------------------------------------------------------------------------------- /solidity/dod/dodDebot.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"options","type":"uint8"}, 9 | {"name":"debotAbi","type":"bytes"}, 10 | {"name":"targetAbi","type":"bytes"}, 11 | {"name":"targetAddr","type":"address"} 12 | ], 13 | "outputs": [ 14 | ] 15 | }, 16 | { 17 | "name": "fetch", 18 | "inputs": [ 19 | ], 20 | "outputs": [ 21 | {"components":[{"name":"id","type":"uint8"},{"name":"desc","type":"bytes"},{"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"actions","type":"tuple[]"}],"name":"contexts","type":"tuple[]"} 22 | ] 23 | }, 24 | { 25 | "name": "getVersion", 26 | "inputs": [ 27 | ], 28 | "outputs": [ 29 | {"name":"name","type":"bytes"}, 30 | {"name":"semver","type":"uint24"} 31 | ] 32 | }, 33 | { 34 | "name": "quit", 35 | "inputs": [ 36 | ], 37 | "outputs": [ 38 | ] 39 | }, 40 | { 41 | "name": "getErrorDescription", 42 | "inputs": [ 43 | {"name":"error","type":"uint32"} 44 | ], 45 | "outputs": [ 46 | {"name":"desc","type":"bytes"} 47 | ] 48 | }, 49 | { 50 | "name": "enterMsigAddress", 51 | "inputs": [ 52 | {"name":"wallet","type":"address"} 53 | ], 54 | "outputs": [ 55 | ] 56 | }, 57 | { 58 | "name": "setText", 59 | "inputs": [ 60 | {"name":"declaration","type":"bytes"} 61 | ], 62 | "outputs": [ 63 | ] 64 | }, 65 | { 66 | "name": "setSigns", 67 | "inputs": [ 68 | {"name":"signatures","type":"uint64"} 69 | ], 70 | "outputs": [ 71 | ] 72 | }, 73 | { 74 | "name": "getTextParam", 75 | "inputs": [ 76 | ], 77 | "outputs": [ 78 | {"name":"str0","type":"bytes"} 79 | ] 80 | }, 81 | { 82 | "name": "getSignParam", 83 | "inputs": [ 84 | ], 85 | "outputs": [ 86 | {"name":"number0","type":"uint64"} 87 | ] 88 | }, 89 | { 90 | "name": "invokeMultisigDebot", 91 | "inputs": [ 92 | ], 93 | "outputs": [ 94 | {"name":"debot","type":"address"}, 95 | {"components":[{"name":"desc","type":"bytes"},{"name":"name","type":"bytes"},{"name":"actionType","type":"uint8"},{"name":"attrs","type":"bytes"},{"name":"to","type":"uint8"},{"name":"misc","type":"cell"}],"name":"action","type":"tuple"} 96 | ] 97 | }, 98 | { 99 | "name": "getDebotOptions", 100 | "inputs": [ 101 | ], 102 | "outputs": [ 103 | {"name":"options","type":"uint8"}, 104 | {"name":"debotAbi","type":"bytes"}, 105 | {"name":"targetAbi","type":"bytes"}, 106 | {"name":"targetAddr","type":"address"} 107 | ] 108 | }, 109 | { 110 | "name": "sign", 111 | "inputs": [ 112 | ], 113 | "outputs": [ 114 | ] 115 | }, 116 | { 117 | "name": "transfer", 118 | "inputs": [ 119 | {"name":"str","type":"bytes"} 120 | ], 121 | "outputs": [ 122 | ] 123 | }, 124 | { 125 | "name": "signers", 126 | "inputs": [ 127 | ], 128 | "outputs": [ 129 | {"name":"signers","type":"map(address,bool)"} 130 | ] 131 | }, 132 | { 133 | "name": "counter", 134 | "inputs": [ 135 | ], 136 | "outputs": [ 137 | {"name":"counter","type":"uint256"} 138 | ] 139 | }, 140 | { 141 | "name": "dodAddress", 142 | "inputs": [ 143 | ], 144 | "outputs": [ 145 | {"name":"dodAddress","type":"address"} 146 | ] 147 | }, 148 | { 149 | "name": "happyHash", 150 | "inputs": [ 151 | ], 152 | "outputs": [ 153 | {"name":"happyHash","type":"uint256"} 154 | ] 155 | } 156 | ], 157 | "data": [ 158 | ], 159 | "events": [ 160 | ] 161 | } 162 | -------------------------------------------------------------------------------- /solidity/dod/dodDebot.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/dod/dodDebot.tvc -------------------------------------------------------------------------------- /solidity/dod/idod.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.6.0; 2 | 3 | interface IDoD { 4 | function sign() external; 5 | } -------------------------------------------------------------------------------- /solidity/elector/Common.sol: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of TON OS. 3 | 4 | TON OS is free software: you can redistribute it and/or modify 5 | it under the terms of the Apache License 2.0 (http://www.apache.org/licenses/) 6 | 7 | Copyright 2019-2021 (c) TON LABS 8 | */ 9 | 10 | pragma ton-solidity >=0.38.0; 11 | 12 | library Common { 13 | 14 | struct Validator { 15 | uint8 tag; // = 0x53 16 | uint32 ed25519_pubkey; // = 0x8e81278a 17 | uint256 pubkey; 18 | uint64 weight; 19 | } 20 | 21 | struct ValidatorAddr { 22 | uint8 tag; // = 0x73 23 | uint32 ed25519_pubkey; // = 0x8e81278a 24 | uint256 pubkey; 25 | uint64 weight; 26 | uint256 adnl_addr; 27 | } 28 | 29 | struct ValidatorSet { // config params 32, 34, 36 30 | uint8 tag; // = 0x12 31 | uint32 utime_since; 32 | uint32 utime_until; 33 | uint16 total; 34 | uint16 main; 35 | uint64 total_weight; 36 | mapping(uint16 => TvmSlice /* Validator or ValidatorAddr */) vdict; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /solidity/elector/Elector.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/elector/Elector.tvc -------------------------------------------------------------------------------- /solidity/elector/IConfig.sol: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of TON OS. 3 | 4 | TON OS is free software: you can redistribute it and/or modify 5 | it under the terms of the Apache License 2.0 (http://www.apache.org/licenses/) 6 | 7 | Copyright 2019-2023 (c) EverX 8 | */ 9 | 10 | pragma ton-solidity >=0.38.0; 11 | 12 | interface IConfig { 13 | 14 | function set_next_validator_set(uint64 query_id, TvmCell vset) 15 | functionID(0x4e565354) external; 16 | 17 | function set_slashed_validator_set(uint64 query_id, TvmCell vset) 18 | functionID(0x4e565355) external; 19 | 20 | function upgrade_code(TvmCell code) external externalMsg; 21 | 22 | function setcode_confirmation(uint64 query_id, uint32 body) 23 | functionID(0xce436f64) external; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /solidity/elector/IElector.sol: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of TON OS. 3 | 4 | TON OS is free software: you can redistribute it and/or modify 5 | it under the terms of the Apache License 2.0 (http://www.apache.org/licenses/) 6 | 7 | Copyright 2019-2023 (c) EverX 8 | */ 9 | 10 | pragma ton-solidity >=0.38.0; 11 | 12 | interface IElector { 13 | /// @dev Allows validator to become validator candidate 14 | function process_new_stake( 15 | uint64 query_id, 16 | uint256 validator_key, 17 | uint32 stake_at, 18 | uint32 max_factor, 19 | uint256 adnl_addr, 20 | bytes signature 21 | ) external functionID(0x4E73744B) internalMsg; 22 | 23 | /// @dev Allows getting back validator's stake 24 | function recover_stake(uint64 query_id) external functionID(0x47657424) internalMsg; 25 | function recover_stake_gracefully(uint64 query_id, uint32 elect_id) external functionID(0x47657425) internalMsg; 26 | 27 | /// @dev Allow getting elector info 28 | function get_elect_at(uint64 query_id) external functionID(0x47657426) internalMsg; 29 | 30 | /// @dev Confirmation from configuration smart contract 31 | function config_set_confirmed_ok(uint64 query_id) external functionID(0xee764f4b) internalMsg; 32 | function config_set_confirmed_err(uint64 query_id) external functionID(0xee764f6f) internalMsg; 33 | 34 | function config_slash_confirmed_ok(uint64 query_id) external functionID(0xee764f4c) internalMsg; 35 | function config_slash_confirmed_err(uint64 query_id) external functionID(0xee764f70) internalMsg; 36 | 37 | /// @dev Upgrade code (is accepted only from configuration smart contract) 38 | function upgrade_code(uint64 query_id, TvmCell code, TvmCell data) external functionID(0x4e436f64) internalMsg; 39 | 40 | struct Complaint { 41 | uint8 tag; // = 0xbc 42 | uint256 validator_pubkey; 43 | TvmCell description; 44 | uint32 created_at; 45 | uint8 severity; 46 | uint256 reward_addr; 47 | uint128 paid; // TODO varuint16 for funC compatibility 48 | uint128 suggested_fine; // TODO 49 | uint32 suggested_fine_part; 50 | } 51 | 52 | /// @dev Register new complaint 53 | //function register_complaint( 54 | // uint64 query_id, 55 | // uint32 election_id, 56 | // Complaint complaint 57 | //) external functionID(0x52674370); 58 | 59 | /// @dev Vote for a complaint 60 | function proceed_register_vote( 61 | uint64 query_id, 62 | uint256 signature_hi, 63 | uint256 signature_lo, 64 | uint32 sign_tag, 65 | uint16 idx, 66 | uint32 elect_id, 67 | uint256 chash 68 | ) external functionID(0x56744370) internalMsg; 69 | 70 | function grant() external functionID(0x4772616e) internalMsg; 71 | function take_change() external internalMsg; 72 | } 73 | -------------------------------------------------------------------------------- /solidity/elector/IValidator.sol: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of TON OS. 3 | 4 | TON OS is free software: you can redistribute it and/or modify 5 | it under the terms of the Apache License 2.0 (http://www.apache.org/licenses/) 6 | 7 | Copyright 2019-2021 (c) TON LABS 8 | */ 9 | 10 | pragma ton-solidity >=0.38.0; 11 | 12 | interface IValidator { 13 | 14 | function return_stake(uint64 query_id, uint32 body) functionID(0xee6f454c) external; 15 | function confirmation(uint64 query_id, uint32 body) functionID(0xf374484c) external; 16 | function receive_stake_back(uint64 query_id) functionID(0xf96f7324) external; 17 | function receive_elect_at(uint64 query_id, bool election_open, uint32 elect_at) functionID(0xf8229612) external; 18 | function error(uint64 query_id, uint32 body) /* functionID(0xfffffffe) */ external; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /solidity/safemultisig/FormalVerification/About: -------------------------------------------------------------------------------- 1 | The current release is powered by Multisig smart contract that, 2 | as all the smart contracts to be issued by TON Labs passed the formal verification 3 | using the proprietary Pruvendo technology invented and developed in cooperation with their partners. 4 | 5 | Pruvendo lays upon Coq theorem prover and formally checks that: 6 | 7 | Multisig works exactly as specified 8 | No logical lockdowns are possible 9 | No extraordinary gas spendings are possible 10 | No asset thieves are possible 11 | No vanishing of assets are possible 12 | Each party spends or acquires the same amount of assets as specified assuming the blockchain works correctly. 13 | No unauthorised or “underauthorised” actions are possible 14 | 15 | 16 | The claims mentioned above are related both to Solidity smart contract source code as well as to compiled 17 | TON Virtual Machine bytecode, thus claiming the compiler layer as formally verified in addition to the source layer. 18 | 19 | As mentioned above Pruvendo technology allows to verify the smart contract both in form of Solidity 20 | source code as well as in the form of the code compiled into TVM Assembler. 21 | 22 | The key ideas of the Solidity verification are listed below: 23 | Solidity code is translated into the “same” pseudo code (fully fledged DSL was developed) written in Coq. 24 | Ability to translate the imperative language into the functional one is achieved by usage of specially designed 25 | stack of state monadic operations and special bindings 26 | 27 | DSL fully supports all the Solidity types including: 28 | Integers (signed and unsigned) 29 | Lists and arrays 30 | Structures 31 | Hashmaps (with certain limitations) 32 | DSL supports the following types of workflow: 33 | Linear (imperative) workflow 34 | Conditions 35 | Functions 36 | Cycles (with certain limitations) 37 | Intristics (with certain limitations) 38 | “require” modifier 39 | 40 | When the pseudo code is obtained all the low-level specification statements 41 | (i.e. statements claiming that the certain blocks of code work as intended by the specification) 42 | are proved using the standard Coq-techniques supported by specially designed abstraction library and API 43 | 44 | Having the proven low-level statements in place the high-level statements 45 | (as mentioned in the beginning of the present article) are proven (also by using the standard Coq-techniques). 46 | 47 | While the technology briefly described above is mostly based on manual efforts, it's planned to semiautomate 48 | (or even, fully automate) them in a foreseeable future. 49 | 50 | The TVM layer is rather different and was built upon the specially developed Coq-base TON Virtual Machine 51 | reference implementation. This machine supports all the primitives used by the Multisig smart contract. 52 | 53 | Then the following steps are performed: 54 | The correct initial state of the Virtual Machine is prepared for each type of entry points 55 | The compiled code of each function (or just a block of code) is being run by a specially designed runner (to be automated soon) 56 | The outcome (terminal state of the Virtual Machine or its elements) is compared to the one suggested by the specification 57 | Thus, the correctness of the TVM code compiled by the TON Labs toolchain is being proven 58 | 59 | The same Pruvendo technology may be applicable for the smart contracts issued by third parties as well. 60 | -------------------------------------------------------------------------------- /solidity/safemultisig/SafeMultisigWallet.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["pubkey", "time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | {"name":"owners","type":"uint256[]"}, 9 | {"name":"reqConfirms","type":"uint8"} 10 | ], 11 | "outputs": [ 12 | ] 13 | }, 14 | { 15 | "name": "acceptTransfer", 16 | "inputs": [ 17 | {"name":"payload","type":"bytes"} 18 | ], 19 | "outputs": [ 20 | ] 21 | }, 22 | { 23 | "name": "sendTransaction", 24 | "inputs": [ 25 | {"name":"dest","type":"address"}, 26 | {"name":"value","type":"uint128"}, 27 | {"name":"bounce","type":"bool"}, 28 | {"name":"flags","type":"uint8"}, 29 | {"name":"payload","type":"cell"} 30 | ], 31 | "outputs": [ 32 | ] 33 | }, 34 | { 35 | "name": "submitTransaction", 36 | "inputs": [ 37 | {"name":"dest","type":"address"}, 38 | {"name":"value","type":"uint128"}, 39 | {"name":"bounce","type":"bool"}, 40 | {"name":"allBalance","type":"bool"}, 41 | {"name":"payload","type":"cell"} 42 | ], 43 | "outputs": [ 44 | {"name":"transId","type":"uint64"} 45 | ] 46 | }, 47 | { 48 | "name": "confirmTransaction", 49 | "inputs": [ 50 | {"name":"transactionId","type":"uint64"} 51 | ], 52 | "outputs": [ 53 | ] 54 | }, 55 | { 56 | "name": "isConfirmed", 57 | "inputs": [ 58 | {"name":"mask","type":"uint32"}, 59 | {"name":"index","type":"uint8"} 60 | ], 61 | "outputs": [ 62 | {"name":"confirmed","type":"bool"} 63 | ] 64 | }, 65 | { 66 | "name": "getParameters", 67 | "inputs": [ 68 | ], 69 | "outputs": [ 70 | {"name":"maxQueuedTransactions","type":"uint8"}, 71 | {"name":"maxCustodianCount","type":"uint8"}, 72 | {"name":"expirationTime","type":"uint64"}, 73 | {"name":"minValue","type":"uint128"}, 74 | {"name":"requiredTxnConfirms","type":"uint8"} 75 | ] 76 | }, 77 | { 78 | "name": "getTransaction", 79 | "inputs": [ 80 | {"name":"transactionId","type":"uint64"} 81 | ], 82 | "outputs": [ 83 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"trans","type":"tuple"} 84 | ] 85 | }, 86 | { 87 | "name": "getTransactions", 88 | "inputs": [ 89 | ], 90 | "outputs": [ 91 | {"components":[{"name":"id","type":"uint64"},{"name":"confirmationsMask","type":"uint32"},{"name":"signsRequired","type":"uint8"},{"name":"signsReceived","type":"uint8"},{"name":"creator","type":"uint256"},{"name":"index","type":"uint8"},{"name":"dest","type":"address"},{"name":"value","type":"uint128"},{"name":"sendFlags","type":"uint16"},{"name":"payload","type":"cell"},{"name":"bounce","type":"bool"}],"name":"transactions","type":"tuple[]"} 92 | ] 93 | }, 94 | { 95 | "name": "getTransactionIds", 96 | "inputs": [ 97 | ], 98 | "outputs": [ 99 | {"name":"ids","type":"uint64[]"} 100 | ] 101 | }, 102 | { 103 | "name": "getCustodians", 104 | "inputs": [ 105 | ], 106 | "outputs": [ 107 | {"components":[{"name":"index","type":"uint8"},{"name":"pubkey","type":"uint256"}],"name":"custodians","type":"tuple[]"} 108 | ] 109 | } 110 | ], 111 | "data": [ 112 | ], 113 | "events": [ 114 | { 115 | "name": "TransferAccepted", 116 | "inputs": [ 117 | {"name":"payload","type":"bytes"} 118 | ], 119 | "outputs": [ 120 | ] 121 | } 122 | ] 123 | } 124 | -------------------------------------------------------------------------------- /solidity/safemultisig/SafeMultisigWallet.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/safemultisig/SafeMultisigWallet.tvc -------------------------------------------------------------------------------- /solidity/setcodemultisig/README.md: -------------------------------------------------------------------------------- 1 | # Setcode Multisignature wallet 2 | SetcodeMultisigWallet - multisignature wallet with setcode. 3 | 4 | More information about multisignature wallet can be read in [SafeMultisig readme](https://github.com/tonlabs/ton-labs-contracts/tree/master/solidity/safemultisig/README.md) -------------------------------------------------------------------------------- /solidity/setcodemultisig/SetcodeMultisigWallet.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ton-labs-contracts/8f7efe34c81aff22d17f190b2c7291d18273b60c/solidity/setcodemultisig/SetcodeMultisigWallet.tvc --------------------------------------------------------------------------------