1.0.32 • Published 1 month ago

dustn v1.0.32

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

DUSTN

A high level smart contract language based with solidity-like syntax for TON Chain

Dustn compiles to Func 4x smaller bytecode vs Tact

Join

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 TypeFunc Type
addressslice
cellcell
stringcell
uint256int
uint128int
uint64int
uint32int
uint16int
uint8int
uint1int
boolint

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

1.0.29

1 month ago

1.0.28

1 month ago

1.0.27

1 month ago

1.0.32

1 month ago

1.0.31

1 month ago

1.0.30

1 month ago

1.0.19

2 months ago

1.0.18

2 months ago

1.0.16

2 months ago

1.0.20

2 months ago

1.0.26

2 months ago

1.0.25

2 months ago

1.0.24

2 months ago

1.0.23

2 months ago

1.0.15

2 months ago

1.0.14

2 months ago

1.0.13

2 months ago

1.0.12

2 months ago

1.0.11

2 months ago

1.0.10

2 months ago

1.0.9

2 months ago

1.0.8

2 months ago

1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago