GLIP
GLIP stands for Glittr Improvement Proposals. There are # standards that are already implemented by the core team and more improvement can be proposed by anyone via GitHub.
Core Standards
The core standards cover mostly the digital assets that can be deployed within the Glittr Ecosystem. Currently only Asset Contracts are implemented by the core team.
Asset Contracts
Simple Asset
Free Mint
Preallocated
Purchase/Burn
Develop New GLIP
For more customized and a lot more complex logic there might be a need to develop a new GLIP. To develop a GLIP, you need to run your own localnode and write a new code that will be validate & process the new transaction based on your own specification. During development you can use the ./watch.sh
to automatically cargo check
and cargo test
your code.
Prerequisites:
Guides:
NOTE: If you prefer to learn from example, you can look into the `GLIP-1: Governance Contract` example.
To create a new GLIP standard, you need to write the new custom logic with RUST into the glittr-core's code. Most of your changes will be inside /src/transaction
Inside /src/transaction/message.rs
add new enum entry to
ContractType (if you want to add new contract)
CallType (if you want to add new call to your contract, or existing contract)
Of course, you need to implement the new ContractType or CallType that you declare. Create a new file under /src/transaction, let's call it custom_contract.rs. This is where all of your OP_RETURN structure is being written. Since we are using rust and serialize it to JSON (for devnet), we are using serde_json
for convenience, don't fret about the serialization. Your contract structure will be using Rust's struct, also you need to implement static validate(&self)
here to validate your contract creation values.
If you have validation that is dependent on the runtime (block height, checking if the token really exist, etc), you must edit the index
function inside src/updater.rs.
In the same file, you can also implement the logic for all your CallTypes.
Make sure you add tests and the previous tests still work as well.
Typescript Library
For every change in the Glittr Core code, we should update the SDK to match the new message format. Example: https://github.com/Glittrfi/glittr-sdk-public/pull/1
ContractType (If you want to add a new
ContractType
message, you should create a new file in/packages/sdk/src/transaction/contract/<new_contract_creation>.ts
) .e.g
CallType (to add new CallType, you should create new file in
/packages/sdk/src/transaction/callType/<new_call_type>.ts
)
After creating a new file in /packages/sdk/src/transaction/contract/
(for new contract creation) and in /packages/sdk/src/transaction/callType/
(for new calltype), we should add new type definition for contract creation in packages/sdk/src/transaction/contract/types.ts
And also add new type definition for call type in packages/sdk/src/transaction/calltype/types.ts
After completing those steps, we can add a new function and message definition for txBuilder
. Edit the file in packages/sdk/src/transaction/message.ts
Now create the function for the txBuilder
in packages/sdk/src/transaction/index.ts
PR Format
For Encode hackathon participant, please make a PR to https://github.com/Glittrfi/glittr-core-public and https://github.com/Glittrfi/glittr-core-public.
Example
We have prepared a GLIP example, in this example we are creating a Governance Contract* : https://github.com/Glittrfi/glittr-core-public/pull/1 * this example is not complete, but you should provide a finished implementation with tests
Last updated