Skip to content

Commit

Permalink
Update Getting Started.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Feb 14, 2024
1 parent fdd52be commit f584e12
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions darc-docs/docs/By-law Script/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,58 @@ import TabItem from '@theme/TabItem';

# Getting Started

## What is By-law Script?
## By-law Script = JavaScript + Operator Overloading

By-law Script is the first programming language for describing the operations and rules for a DARC-based crypto company.
By-law Script is the first programming language for describing the operations and rules for a DARC-based crypto company. It is a domain-specific language (DSL) that is designed to be easy to read and write, and to be used by non-programmers. It is based on JavaScript, and adds operator overloading to make it easier to write and read.

## Your First By-law Script Program

Here is a simple By-law Script program that defines the common stock of a company. Each share of common stock has voting weight 1 and dividend weight 1. This token class is called `token_0`, and the token index is 0.

```javascript
batch_create_token_classes(
['token_0'], // token names
[0], // token index
[1], // voting weights
[1]); // dividend weights
```

Next let's issue 1000 shares of `token_0` to the company's founder, 500 shares to Address_A, 400 shares to Address_B, and 100 shares to Address_C.

```javascript
cosnt Address_A = "0x1234567890123456789012345678901234567890";
cosnt Address_B = "0x1234567890123456789012345678901234567891";
cosnt Address_C = "0x1234567890123456789012345678901234567892";
batch_mint_tokens(
[ Address_A, Address_B, Address_C], // the addresses of the recipients
[0,0,0], // the token index
[500,400,100]); // the amounts
```

Then Address_A executes the following By-law Script on this DARC to transfer 100 shares of `token_0` to Address_B.

```javascript
batch_transfer_tokens(
[Address_B], // the addresses of the recipients
[0], // the token index
[100]); // the amounts
```

As a customer, Address_D needs to pay 1000000 wei to the DARC for the service. The following By-law Script is executed by Address_D.

```javascript
pay_cash(
1000000, // the amount = 1000000 wei
0, // the payment type = 0, the default native token
1); // the dividendable flag, 1 means the payment is dividendable
```

Finally, Address_C wants to issue dividends to all token holders. The following By-law Script is executed by Address_C.

```javascript
offer_dividends();
```

## Your First Plugin as a Law

The plugin is an object that contains all necessary information

0 comments on commit f584e12

Please sign in to comment.