Trillium 1.4.0
dotnet add package Trillium --version 1.4.0
NuGet\Install-Package Trillium -Version 1.4.0
<PackageReference Include="Trillium" Version="1.4.0" />
paket add Trillium --version 1.4.0
#r "nuget: Trillium, 1.4.0"
// Install Trillium as a Cake Addin #addin nuget:?package=Trillium&version=1.4.0 // Install Trillium as a Cake Tool #tool nuget:?package=Trillium&version=1.4.0
Trillium
Trillium is the smart contract language that will be powering our smart contracts. This is a from scratch language that has roots from C#, C, and some Javascript.
Core Features (Statements, expressions, etc)
This language is turing complete and has many features. Below are most of the current implemented features:
- Numbers (ints)
- Strings ("Any")
- Booleans (true, false)
- Addition ('+')
- Subtraction ('-')
- Multiplication ('*')
- Division ('/')
- Basic Operator Tokens(&, !, ^, |, =, (, ), >, <, [, ], :, ',', &&, !=, ^=, ==, >=, ⇐, and more)
- If Statements
- Else Statements
- Else If Statements
- Returns
- While Loops
- For Loops
- Do While Statements
- Block Statements
- Expressions
- Variable Declaration
- LiteralExpression,
- Name Expression
- Unary Expression
- Binary Expression
- Parenthesized Expression
- Assignment Expression
- Call Expression
Examples
The Languages purpose is to drive all self-executing NFT (SENs) functions.
Some examples are below:
function HelloPerson(name : string) : string
{
var text = "Hello " + name
return text
}
HelloPerson("Trillium")
outputs Hello Trillium
12 + 12 -> press enter
outputs 24
function WhoAmI(age : int, name : string)
{
if name == "Trillium" && age == 99
{
print("Hi " + name)
}
else
{
print("Hello, sorry but we don't know you")
}
}
outputs "Hi Trillium" if name = "Trillium" and age = 99 outputs "Hello, sorry but we don't know you" for everything else
You can define variables as such:
{
var name : string = "Some Name" (or var name = "Some Name")
var number : int = 22 (or var number = 22)
var truth : bool = true (or var truth = true)
}
Lets make a basic two number calculator where we pass in the operator as a string
function calculator(firstNum : int, secondNum : int, operator : string) : string
{
var result = 0
if operator == "+"
{
result = firstNum + secondNum
return string(result)
}
else if operator == "-"
{
result = firstNum - secondNum
return string(result)
}
else if operator == "*"
{
result = firstNum * secondNum
return string(result)
}
else if operator == "/"
{
result = firstNum / secondNum
return string(result)
}
else
{
return "No known operator was given"
}
}
calculator(2, 2, "+")
output is 4
Trillium is constantly growing and will evolve over time to support more functions and have more built in features to reduce code writing.
Things to do
- Emit IL
- Nullable types
- Comments (May not do this to keep source code files smaller)
Setup
- Install Visual Studio 2022 or latest version of Visual Code
- .Net Core 6
- Download the Trillium repo from GitHub
- Open the Trillium.sln file in Visual Studio or open the src folder in VS Code
Testing
To write and test your own contracts first follow the setup instructions above. Next you will want to run the TrilliumI project. This will open the REPL in the CLI and allow you to being writing natively in Trillium and getting results. The REPL provides full diagnostics, so you will know exactly what is wrong within your statements of code.
Who do I talk to?
- Repo owner or admin
- Other community or team contact
- https://discord.gg/PnS2HRETDh
People to Thank and Sources
The language was modeled after the language courses from Microsoft's Immo Landwerth and adapted further to work within the ReserveBlocks core wallet infastructure.
Some other references to site are (please note none of these people worked on the project, but rather provided material to help make this. They are in no way affiliated with this project):
- Clinton L. Jeffery and his Books
- Jon Skeet and his C# In Depth books
- Alex Williams and his debugging methodology
- Immo Landwerth and his series
License
Trillium is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.