Rift The Magical Python -> TON Portal
Develop Smart Contracts directly in Python!💫 Rift brings easy development of TON Smart Contracts to Python, you can simply take advantage of Python’s syntax and capabilities to develop on TON.
1 class SimpleWallet(Contract): 2 """ 3 Simple Wallet Contract. 4 5 # config 6 get-methods: 7 - seq_no 8 - public_key 9 """ 10 11 class Data(Model): 12 seq_no: uint32 13 public_key: uint256 14 15 class ExternalBody(SignedPayload): 16 seq_no: uint32 17 valid_until: uint32 18 19 data: Data 20 21 def external_receive(self) -> None: 22 msg = self.body % self.ExternalBody 23 assert msg.valid_until > std.now(), 35 24 assert msg.seq_no == self.data.seq_no, 33 25 assert msg.verify_signature(self.data.public_key), 34 26 std.accept_message() 27 while msg.refs(): 28 mode = msg >> uint8 29 std.send_raw_message(msg >> Ref[Cell], mode) 30 self.data.seq_no += 1 31 self.data.save()
Interact easily with TON!💎 Rift is the ultimate wrapper around TON development tools. You can:
  • Build messages, sign them (Fift Backend)
  • Run contract codes, pass objects back and forth (TVM Backend)
  • Deploy contracts, interact with the network (Tonlibjson Backend)
1 from contracts.jetton_minter import JettonMinter 2 from contracts.jetton_wallet import JettonWallet 3 4 5 def deploy(): 6 init_data = JettonMinter.Data() 7 init_data.admin = "EQCDRmpCsiy5fA0E1voWMpP-L4SQ2lX0liTk3zgFXcyLSYS3" 8 init_data.total_supply = 10**11 # 100 9 init_data.content = Cell() 10 init_data.wallet_code = JettonWallet.code() 11 msg, addr = JettonMinter.deploy(init_data, amount=2 * 10 ** 8) 12 return msg, False
Battle-test your contracts with Rift!🧪 Rift provides a TVM testing framework, making it easy to test contracts carefully before going into the production. It provides simple interface to create message bodies and inspect contract's state to ensure the correct behavior.
1 from contracts.jetton_wallet import JettonWallet 2 from contracts.types import TransferBody 3 4 5 def test_transfer(): 6 data = create_data().as_cell() 7 wallet = JettonWallet.instantiate(data) 8 body = create_transfer_body(dest=3) 9 res = wallet.send_tokens( 10 body.as_cell().parse(), MsgAddress.std(0, 2), int(10e9), 0, 11 ) 12 res.expect_ok() 13 14 15 def test_transfer_no_value(): 16 data = create_data().as_cell() 17 wallet = JettonWallet.instantiate(data) 18 body = create_transfer_body(dest=3) 19 res = wallet.send_tokens( 20 body.as_cell().parse(), MsgAddress.std(0, 2), 0, 0, 21 ) 22 res.expect_error()
© 2023 Skyring Opensource. All Rights Reserved