pragma tvm-solidity >= 0.72.0; pragma AbiHeader expire; /// @title Simple wallet contract Wallet { /* Exception codes: 100 - message sender is not a wallet owner. 101 - invalid transfer value. */ /// @dev Contract constructor. constructor() { // check that contract's public key is set require(tvm.pubkey() != 0, 101); // Check that message has signature (msg.pubkey() is not zero) and message is signed with the owner's private key require(msg.pubkey() == tvm.pubkey(), 102); tvm.accept(); } // Modifier that allows function to accept external call only if it was signed // with contract owner's public key. modifier checkOwnerAndAccept { // Check that inbound message was signed with owner's public key. // Runtime function that obtains sender's public key. require(msg.pubkey() == tvm.pubkey(), 100); // Runtime function that allows contract to process inbound messages spending // its own resources (it's necessary if contract should process all inbound messages, // not only those that carry value with them). tvm.accept(); _; } /// @dev Allows to transfer tons to the destination account. /// @param dest Transfer target address. /// @param value Nanoevers value to transfer. /// @param bounce Flag that enables bounce message in case of target contract error. function sendTransaction(address dest, coins value, bool bounce) external view checkOwnerAndAccept { // Runtime function that allows to make a transfer with arbitrary settings. dest.transfer(value, bounce, 0); } }