Skip to main content

A magical Python3 -> FunC portal

Project description

Rift

PyPI version Telegram Telegram

A magical Python3 -> FunC portal

Rift is smart contract development framework in Python for TON (The Open Network). Its purpose is to make the development, testing, and deployment procedures much easier!

Goals

  • To be a simple full-stack Python framework for developing on the TON ecosystem
  • Make standard contract implementations available (similar to OpenZeppelin)
  • Utilize Python's syntax to provide code reuse, understandable, and organized code that is simple to test

Overview

Rift's main purpose is to make contract building simpler for TON by bypassing the steep learning curve of FunC. Rift, by exploiting Python's OOP features, will enable you to create with more ease and less worry. In Rift, here is how the Simple wallet contract looks:

from rift import *


class SimpleWallet(Contract):
    """
    Simple Wallet Contract.

    # config
    get-methods:
        - seq_no
        - public_key
    """

    class Data(Model):
        seq_no: uint32
        public_key: uint256

    class ExternalBody(Payload):
        signature: slice[512]
        seq_no: uint32
        valid_until: uint32

    data: Data

    def external_receive(
        self,
        in_msg: Slice,
    ) -> None:
        msg = self.ExternalBody(in_msg)
        assert msg.valid_until > std.now(), 35
        assert msg.seq_no == self.data.seq_no, 33
        assert std.check_signature(
            msg.hash(after="signature"),
            msg.signature,
            self.data.public_key,
        ), 34
        std.accept_message()
        while msg.refs():
            mode = msg >> uint8
            std.send_raw_message(msg >> Ref[Cell], mode)
        self.data.seq_no += 1
        self.data.save()

Quick Start

  1. Install Python 3.10+
  2. Install rift
pip install rift-framework
# or from source
git clone https://github.com/sky-ring/rift
cd rift
pip install -e .
  1. Initialize your project:
rift init <project-name>
  1. Start developing your contracts in <project>/contracts/
  2. Build contracts and get the FunC contracts in <project>/build/
# in project folder
rift build

Standard Contracts Implementation

  • Jetton Implementation (jetton-impl)
  • NFT Implementation
  • DEX Implementation

Documentation and Examples

Full documentation with specifications is being developed and will be available shortly! Until then, you may look at standard contracts implementation; they cover the majority of the ideas required; if you're looking for more, take a glance at the 'test/' directory for some demonstrations of Rift's capabilities.

Roadmap

Milestone 1: Python Framework for contract development

  • Semi One-to-One mapping of functions and expressions (Base Compiler, Python -> FunC)
  • First higher layer over the base mappings to simplify type calls (leveraging OOP capabilities)
  • Second higher layer over the base, simplifying contract developments towards maximizing code reusability and simplicity (leveraging Meta programming capabilities)
  • Providing standard smart contracts implementation with Rift

Milestone 2: deploying, testing, interaction capabilities

  • Simple interaction interface with TON Blockchain
  • Simple deploying options of developed contracts
  • Testing framework for the contracts developed with Rift

Contributing

If you're interested in contributing to Rift, please see CONTRIBUTING.md for the necessary specifications and procedure.

Supporters

Special thanks to the TON Society for their support and grant, without which the project would not be feasible.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rift-framework-0.7.5.tar.gz (41.0 kB view hashes)

Uploaded Source

Built Distribution

rift_framework-0.7.5-py3-none-any.whl (64.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page