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 tokens.
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.
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
I guarantee you that if you try to understand you will understand. The code examples should
explain themselves.
from trilio import Trilio
blockchain = Trilio()
from trilio import Trilio
blockchain = Trilio()
valid = blockchain.validate_chain() # True = Valid, False = Invalid
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
from trilio import Trilio
blockchain = Trilio()
wallet = blockchain.Wallet.create_wallet() # Will return json with wallet information
from trilio import Trilio
blockchain = Trilio()
wallet = blockchain.Wallet.create_wallet()
address = wallet["address"]
address["pve"] # Private key
address["pbc"] # Public key
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
blockchain.Wallet.get_public_key(private_key=<private_key>)
blockchain.Wallet.credit_wallet(public_key=<public_key>, amount=<amount>)
blockchain.Wallet.validate_wallet(private_key=<private_key>, public_key=<public_key>) # True = found, False = not found
# 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>
}
}
)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"asset-transfer",
"data":{
"_to":<public_key_receiver>,
"_from":<private_key_sender>,
"fassets":[<sending_assets_id>],
"tassets":[<receiving_assets_id>]
}
}
)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"contract-action",
"action":"accept-trade",
"data":{
"id":<trade_id>,
"signer":<private_key>
}
}
)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"contract-action",
"action":"decline-trade",
"data":{
"id":<trade_id>,
"signer":<private_key>
}
}
)
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>))
Assets are basically a fancy name for NFTs, you would need a collection owned by you to mint an NFT.
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"contract-action",
"action":"asset-creation",
"data":{
"name":<asset_name>,
"description":<asset_description>,
"collection_id":<collection_id>,
"quantity":<asset_mint_amount>,
"signer":<private_key>
}
}
)
#print(blockchain.Wallet.get_assets(private_key=<private_key>, public_key=<public_key>))
Check out Trilio's license.