Trilio icon indicating copy to clipboard operation
Trilio copied to clipboard

Trilio is a blockchain written in Python that utilizes the proof-of-stake concept and helps creating a more smooth and transparent transaction experience, with multiple integrations such as NFT(s) and...

Trilio - A blockchain written in Python

Even though I don't know much about blockchain technology or how it works at all, I've decided to create my own blockchain with consensus algorithm Proof-of-Stake (PoS). I've lately been working with Solidity and been learning about smart-contract development, and during I found it quite fun and interesting. That is why this has and is a very fun project to work on, and even though it might not be classed as a blockchain I've learned a lot during research and improved my Python skills a lot!


Contributions are highly appreciated.

Benifits of Trilio

  • Ultra fast transactions.
  • Simple to understand and use.
  • Integrated smart-contract.

Requirements

Usage

  • Getting Started with Trilio
    • Requirements
    • Installation
  • Usage Examples
    • Blockhain
      • Make your own Blockchain
      • Validate your Blockchain
      • Trilio's blockchain attributes
    • Wallet
      • Create a Wallet
      • Get wallet Keys
      • Convert wallet Key
      • Credit a Wallet
      • Validate a Wallet
    • Transactions
      • Send tokens to Wallet
      • Create your Collection
  • Contact Me
  • License

Get started with Trilio

Installation

In order to make the installation much faster and simpler, I've uploaded this project to PyPi and you can simply install it using the pip command below.

$ pip install trilio==0.1.9

You might also need to pip install these libraries, too.

$ pip install datetime
$ pip install hashlib

Usage Examples

I guarantee you that if you try to understand you will understand. The code examples should
explain themselves.

Blockchain

Make your own Blockchain

from trilio import Trilio

blockchain = Trilio()

Validate your Blockchain

from trilio import Trilio

blockchain = Trilio()
valid = blockchain.validate_chain() # True = Valid, False = Invalid

Trilio's blockchain attributes

These blockchain attributes are already set, but you can change them to whatever you desire.

blockchain.trilio.difficulity = 5 # change the mining complexity

blockchain.trilio.name = "MyBlochainName" # change the name of your blockchain

blockchain.trilio.minimum_transactions = 1 # minimum transactions for each block

Wallet

Create a Wallet

from trilio import Trilio

blockchain = Trilio()
wallet = blockchain.Wallet.create_wallet() # Will return json with wallet information

Get wallet Keys

from trilio import Trilio

blockchain = Trilio()
wallet = blockchain.Wallet.create_wallet()
address = wallet["address"]
address["pve"] # Private key
address["pbc"] # Public key

Get wallet Attributes

blockchain.Wallet.get_balance(private_key=<private_key>, public_key=<public_key>) # Get a wallet's balance
blockchain.Wallet.get_assets(private_key=<private_key>, public_key=<public_key>) # Get a wallet's assets
blockchain.Wallet.get_collections(private_key=<private_key>, public_key=<public_key>) # Get a wallet's collections

Convert wallet Key

blockchain.Wallet.get_public_key(private_key=<private_key>)

Credit a Wallet

blockchain.Wallet.credit_wallet(public_key=<public_key>, amount=<amount>)

Validate a Wallet

blockchain.Wallet.validate_wallet(private_key=<private_key>, public_key=<public_key>) # True = found, False = not found

Transactions

Send tokens to Wallet

# Need to import datetime
blockchain.create_transaction(
    datetime.now(),
    data = {
        "type":"token-transfer",
        "data":{
            "to":<public_key (Wallet recieving)>,
            "from":<private_key (Wallet sending)>,
            "amount":<amount>
        }
    }
)

Create your Collection

Collections are used to sort assets/NFTs to different categories, therefore we can also call collections "categories".

# Need to import datetime
blockchain.create_transaction(
    datetime.now(),
    data = {
        "type":"contract-action",
        "action":"collection-creation",
        "data":{
            "name":<collection_name>,
            "description":<collection_description>,
            "url":<collection_url>,
            "icon":<collection_icon>,
            "tags":<collection_tags>,
            "signer":<private_key>
        }
    }
)

#print(blockchain.Wallet.get_collections(private_key=<private_key>, public_key=<public_key>))

Contact me

Discord: LocalMOD#3782

License

Check out Trilio's license.