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.
Trilio - A blockchain written in Python
UPDATE: I see a lot of things I could improve when I revisit this project.
Contributions are highly appreciated.
Benifits of Trilio
- Ultra fast transactions.
- Simple to understand and use.
- Integrated smart-contract.
Requirements
- Trilio requires Python v3.4+
Usage
- Requirements - Installation - 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 - Send trade to Wallet - Accept a Trade - Decline a Trade - Create your Collection - Create your AssetGet 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.getbalance(privatekey=<privatekey>, publickey=<public_key>) # Get a wallet's balance
blockchain.Wallet.getassets(privatekey=<privatekey>, publickey=<public_key>) # Get a wallet's assets
blockchain.Wallet.getcollections(privatekey=<privatekey>, publickey=<public_key>) # Get a wallet's collections
Convert wallet Key
blockchain.Wallet.getpublickey(privatekey=<privatekey>)
Credit a Wallet
blockchain.Wallet.creditwallet(publickey=<public_key>, amount=<amount>)
Validate a Wallet
blockchain.Wallet.validatewallet(privatekey=<privatekey>, publickey=<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>
}
}
)
Send trade to Wallet (currently broken)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"asset-transfer",
"data":{
"to":<publickey_receiver>,
"from":<privatekey_sender>,
"fassets":[<sendingassetsid>],
"tassets":[<receivingassetsid>]
}
}
)
Accept a Trade(currently broken)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"contract-action",
"action":"accept-trade",
"data":{
"id":<trade_id>,
"signer":<private_key>
}
}
)
Decline a Trade(currently broken)
# Need to import datetime
blockchain.create_transaction(
datetime.now(),
data={
"type":"contract-action",
"action":"decline-trade",
"data":{
"id":<trade_id>,
"signer":<private_key>
}
}
)
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.getcollections(privatekey=<privatekey>, publickey=<public_key>))
Create your Asset
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>,
"collectionid":<collectionid>,
"quantity":<assetmintamount>,
"signer":<private_key>
}
}
)
#print(blockchain.Wallet.getassets(privatekey=<privatekey>, publickey=<public_key>))
Contact me
Discord: LocalMOD#3782License
Check out Trilio's license.