# dustn

> Dustin: High Level Smart Contract for TON Chain

Latest version **1.0.32** (published 2024-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install dustn
pnpm add dustn
yarn add dustn
bun add dustn
```

Provides the command `dustn`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.32 |
| Published | 2024-03-29 |
| First published | 2024-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 12 |
| Unpacked size | 4.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mikey Molina |
| Maintainers | xircusteam |

## Links

- npm: https://www.npmjs.com/package/dustn
- npm.io page: https://npm.io/package/dustn

## Dependencies (12)

- [ejs](https://npm.io/package/ejs.md) ^3.1.9
- [glob](https://npm.io/package/glob.md) 9.3.2
- [chalk](https://npm.io/package/chalk.md) ^5.3.0
- [crc-32](https://npm.io/package/crc-32.md) ^1.2.2
- [@ton/ton](https://npm.io/package/@ton/ton.md) ^13.11.1
- [@ton/core](https://npm.io/package/@ton/core.md) ^0.56.2
- [commander](https://npm.io/package/commander.md) ^10.0.0
- [snakecase](https://npm.io/package/snakecase.md) ^1.0.0
- [@ton/crypto](https://npm.io/package/@ton/crypto.md) ^3.2.0
- [ton-compiler](https://npm.io/package/ton-compiler.md) ^2.3.0
- [@poppinss/prompts](https://npm.io/package/@poppinss/prompts.md) ^3.1.2
- [@solidity-parser/parser](https://npm.io/package/@solidity-parser/parser.md) ^0.18.0

## Recent versions

- 1.0.32 (latest) — 2024-03-29
- 1.0.31 — 2024-03-29
- 1.0.30 — 2024-03-29
- 1.0.29 — 2024-03-29
- 1.0.28 — 2024-03-29
- 1.0.27 — 2024-03-29
- 1.0.26 — 2024-03-24
- 1.0.25 — 2024-03-24
- 1.0.24 — 2024-03-24
- 1.0.23 — 2024-03-24
- 1.0.20 — 2024-03-24
- 1.0.19 — 2024-03-24
- 1.0.18 — 2024-03-24
- 1.0.16 — 2024-03-24
- 1.0.15 — 2024-03-23
- … 14 more at https://npm.io/package/dustn/versions

## 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](https://docs.tact-lang.org/)

## Join
- [Dustin Telegram Group](https://t.me/dustin_lang)
- For contributors, testers and devs, message [Web3Mikey](https://t.me/drybfounder)

## 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 |


- [TON Func Reference](https://docs.ton.org/develop/func/overview)
- [Examples](https://www.npmjs.com/package/dustn?activeTab=code)


### 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

---
_Source: https://npm.io/package/dustn · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
