Steem On-chain Token Protocol Draft
Hi I am back with an improved steem token protocol which is called SPTP for now. The protocol name might be changed.
Basically it is an one method to create a token on STEEM without changing any code of the current steem code.
This protocol is on-chain solution which does not use any other off-chain data.
But to handle the token data, it needs a special program running on a node.
I took inspiration from Bitcoin's Runes protocol for this idea.
And I noticed I can put a function in the block so that a program can read and execute the function. This feature will be used to validate a token creation.
The whitepaper is an initial draft and helped by Claude 3.5 Sonnet. But the idea is from myself @etainclub.
Any comments and feedbacks are welcome.
TL;DR
SPTP is an innovative protocol that leverages existing features of the Steem blockchain to create and manage custom tokens. Key aspects include:
- Token creation and management via Steem posts
- Token transfers using Steem's custom_json operations
- On-chain protocol definition and validation rules
- Dynamic code execution for token validation in a sandboxed environment
- Decentralized token balance management through SPTP nodes
The protocol allows for creating various token-based applications on Steem without modifying the core blockchain. It uses Steem's native features for data storage and transmission, while SPTP nodes handle the interpretation and execution of the protocol rules.
SPTP (Steem Post-Based Token Protocol) Whitepaper
1. Overview
The Steem Post-Based Token Protocol (SPTP) is an innovative protocol that leverages existing features of the Steem blockchain to create, manage, and transfer user-defined tokens. SPTP implements a fully on-chain token system by utilizing Steem's posting and custom JSON functionalities.
2. Background
While the Steem blockchain provides powerful content creation and curation features, it lacked native support for user-defined tokens. SPTP bridges this gap, enabling the development of various token-based applications within the Steem ecosystem.
3. Protocol Structure
3.1 Protocol Definition Post
A Steem post that defines the protocol rules and token creation/management logic. Here's a concrete example:
{
"protocol_version": "1.1",
"protocol_name": "SPTP",
"token_creation_rules": {
"symbol_format": "^[A-Z]{3,7}$",
"max_supply_format": "^[0-9]{1,10}\\.[0-9]{0,8}$",
"required_fields": ["symbol", "name", "max_supply", "precision"]
},
"token_issuance_rules": {
"issuer_must_be_creator": true,
"max_issuance_per_operation": "1000000.00000000"
},
"token_transfer_rules": {
"min_transfer_amount": "0.00000001"
},
"validation_function": "
function validateToken(tokenData) {
if (!/^[A-Z]{3,7}$/.test(tokenData.symbol)) {
return [false, 'Invalid symbol format'];
}
if (!/^[0-9]{1,10}\\.[0-9]{0,8}$/.test(tokenData.max_supply)) {
return [false, 'Invalid max supply format'];
}
if (tokenData.precision < 0 || tokenData.precision > 8) {
return [false, 'Precision must be between 0 and 8'];
}
return [true, 'Token data is valid'];
}
",
"created_tokens": []
}
3.2 Token Creation Post
The post format for creating a new token:
{
"protocol": "SPTP",
"protocol_post": "sptp_admin/sptp-protocol-v1.1",
"action": "create_token",
"token_data": {
"symbol": "EXAMPLE",
"name": "Example Token",
"max_supply": "1000000.00000000",
"precision": 8,
"metadata": {
"website": "https://exampletoken.com",
"logo": "https://exampletoken.com/logo.png"
}
}
}
3.3 Token Transfer
Token transfers are conducted through Steem's custom_json
operations:
{
"required_auths": ["sender_account"],
"required_posting_auths": [],
"id": "sptp_transfer",
"json": {
"symbol": "EXAMPLE",
"amount": "100.00000000",
"to": "receiver_account",
"memo": "Payment for services"
}
}
4. Technical Details
4.1 Token Creation and Validation Process
- A user creates a token creation post.
- An SPTP node detects and processes this post.
- The node executes the
validation_function
from the protocol definition post to validate the token data. - If validation succeeds, the node calculates a hash of the token creation information.
- The node adds this hash as a comment to the protocol definition post.
4.2 Token Balance Management
SPTP manages token balances as follows:
On-chain Transaction Record: All token transfers are recorded as
custom_json
operations on the Steem blockchain.Off-chain State Management: SPTP nodes analyze all token transfer transactions to calculate and manage token balances for each account.
Balance Calculation Method:
- Initial Issuance: The amount specified at token creation
- Received Amount: Sum of all transfers received by the account
- Sent Amount: Sum of all transfers sent by the account
- Current Balance = Initial Issuance + Received Amount - Sent Amount
Indexing and Caching: For quick balance queries, SPTP nodes maintain indices by account and token, and periodically cache balances.
Regular State Validation: Nodes periodically re-validate the entire transaction history to ensure balance accuracy.
4.3 Dynamic Function Execution
SPTP uses RestrictedPython to safely execute the validation function included in the protocol definition post:
class SPTPFunctionExecutor:
def execute_validation_function(self, function_str, token_data):
# Safe function execution logic using RestrictedPython
...
5. Token Creation Example
Here's a concrete example of creating an "EXAMPLE" token using SPTP:
Check Protocol Definition Post:
- The user checks the current protocol rules in the "sptp_admin/sptp-protocol-v1.1" post.
Write Token Creation Post:
{ "protocol": "SPTP", "protocol_post": "sptp_admin/sptp-protocol-v1.1", "action": "create_token", "token_data": { "symbol": "EXAMPLE", "name": "Example Token", "max_supply": "1000000.00000000", "precision": 8, "metadata": { "website": "https://exampletoken.com", "logo": "https://exampletoken.com/logo.png", "description": "This is an example token for demonstration purposes." } } }
SPTP Node Processing:
- The node detects this post and executes the validation function.
- Upon successful validation, the node calculates a hash of the token creation information.
Hash Recording:
- The node adds the following comment to the protocol definition post:
{ "action": "token_created", "symbol": "EXAMPLE", "creator": "user123", "creation_tx": "user123/create-example-token-post", "hash": "a1b2c3d4e5f6..." }
- The node adds the following comment to the protocol definition post:
Token Issuance:
- The token creator executes the following
custom_json
operation to issue initial tokens:{ "required_auths": ["user123"], "required_posting_auths": [], "id": "sptp_issue", "json": { "symbol": "EXAMPLE", "amount": "100000.00000000", "to": "user123" } }
- The token creator executes the following
This completes the successful creation and initial issuance of the "EXAMPLE" token.
6. Security Considerations
- All token operations utilize Steem's existing permission system.
- Dynamic function execution occurs in a restricted environment to enhance security.
- Multiple independent SPTP nodes can cross-validate each other's results.
7. Applications
Potential applications leveraging SPTP include:
- Community point systems
- Digital asset representation
- Voting and governance tokens
- Reward programs
- Decentralized Exchange (DEX) implementation
8. Conclusion
SPTP provides a powerful and flexible token system by leveraging existing features of the Steem blockchain. This protocol opens up new possibilities in the Steem ecosystem and is expected to facilitate the development of various decentralized applications.
9. References
- Steem Whitepaper
- RestrictedPython Documentation
- Bitcoin Colored Coins
- Ethereum ERC-20 Token Standard
Posted through the ECblog app (https://blog.etain.club)
In my opinion any projects which would enhance the STEEM user experience would be very good @etainclub and although I have not much clue on its technical know-how, I must say that it is quite difficult to do unless users and developers alike would collaborate to make such projects come into reality. (^_^)/
UX is being handled by other developers.
The token protocol might intrigue people to make something interesting on steem.
We should have steem engine ... so we can deal with any coin 🪙
This protocol does not need side chain like steem engine. All data are stored on steem blockchain. This is on-chain solution which i intented.
This is good way i love it
안녕하세요. 오늘(2024.07.01) 기준 @jsup 2.0 후원 보팅 현황입니다.
jsup 2.0 - 업보팅을 다시 위대하게
@happycoachmate -> @etainclub : 410.17sp
@jungjunghoon -> @etainclub : 513.27sp
@jsup에 임대하시면 매일 업보팅을 받으며, 23일후부터 매일 큐레이션/패시브 보상을 받습니다. 후원 내역이 있을 경우 임대량에 합산되어 보팅됩니다. 개발자(@joviansummer) 지원 보팅 외에 수수료가 없어 수익률도 우수합니다. 많은 관심 부탁드립니다. 감사합니다.