dustn
v1.0.32
Published
Dustin: High Level Smart Contract for TON Chain
Downloads
12
Readme
DUSTN
A high level smart contract language based with solidity-like syntax for TON Chain
Dustn compiles to Func 4x smaller bytecode vs Tact
- Inspired by Tact Language
Join
- Dustin Telegram Group
- For contributors, testers and devs, message Web3Mikey
Why?
- We want a developer friendly smart contract
- We want a shorter and optimized code
- We want a smaller bytecode on compilation
- We want a language that writes on both func, fift and base64
Initialize Your Project
npx dustn init
Create a Dustin Smart Contract
npx dustn create ContractName
Compiles the contract
npx dustn compile ContractName
Reference
| Data Type | Func Type | |---|---| | address | slice | | cell | cell | | string | cell | | uint256 | int | | uint128 | int | | uint64 | int | | uint32 | int | | uint16 | int | | uint8 | int | | uint1 | int | | bool | int |
Create receiver methods on the fly with operation codes for internal functions
/// Adds const op::mint = "op::mint"c; in the header
function mint(address sender, address toAddress, uint256 amount) internal {}
/// Adds int op::mint() asm "0x12345 PUSHINT";
function mint_12345(address sender, address toAddress, uint256 amount) internal {}
Automatically generates the crc32c Method HEX ID
/// Adds int op::mint() asm "0xe4a55bbc PUSHINT";
function mint_asm(address sender, address toAddress, uint256 amount) internal {}
Features
- Dynamically creates save_data and load_data
- Internal functions as operations
- Optimized getter functions via external
- Extract and fill function parameters from message body
- Instantly generates the opcodes
- Instantly generates operation via internal functions
- Ability to reuse internal functions
- Added support for dictionaries or hashmap
Simple Counter
contract Counter {
uint32 id;
uint32 counter;
function increment_asm(uint32 increasedBy) internal {
counter += increasedBy;
id += 1;
}
function getCounter() public returns(uint32) {
return counter;
}
function getID() public returns(uint32) {
return id;
}
}
To Func
int op::increment() asm "0xe4a55bbc PUSHINT";
slice verify_address(slice address) inline {
throw_unless(136, address.slice_bits() == 267);
var h = address.preload_uint(11);
throw_if(137, h == 1279);
throw_unless(136, h == 1024);
return address;
}
_ load_data() inline {
var ds = get_data().begin_parse();
return (
ds~load_uint(32),
ds~load_uint(32)
);
}
() save_data(int $id, int $counter) impure inline {
set_data(
begin_cell()
.store_uint($id, 32)
.store_uint($counter, 32)
.end_cell()
);
}
() internal_increment(int $increasedBy) impure {
(int $id, int $counter) = load_data();
$counter += $increasedBy;
$id += 1;
save_data($id, $counter);
}
() recv_internal(int $msgBalance, int $msgValue, cell in_msg_full, slice in_msg_body) impure {
if (in_msg_body.slice_empty?()) { ;; ignore all empty messages
return ();
}
var cs = in_msg_full.begin_parse();
var msg_flags = cs~load_uint(4);
var $bounced = -(msg_flags & 1);
slice $sender = verify_address(cs~load_msg_addr());
if ($bounced) {
return ();
}
int $op = in_msg_body~load_uint(32);
int $queryId = in_msg_body~load_uint(64);
if ($op == op::increment()) {
int $increasedBy = in_msg_body~load_uint(32);
internal_increment($increasedBy);
return ();
}
throw(0xffff);
}
(int) get_counter() method_id {
(_, int $counter) = load_data();
return $counter;
}
(int) get_id() method_id {
(int $id, _) = load_data();
return $id;
}
To Base64 Code
te6ccgEBCAEAgAABFP8A9KQT9LzyyAsBAgFiAgMCAs0EBQIBbgYHAFnTYREGOASK3wAOhpgZg42FHImHBpj+mfmMEIclKt3gldSumPmHgCcBhCB/l4QALddqJoaY/pj5gsUADSAIDkZY/lj+T2qkABe1Rz2omhpj+mPmBhAAF7Y//aiaGmP6Y+YGMA==
Bytecode Size: 0.000139 MB
🫰 Handcrafted in ❤️ by Xircus