aboutsummaryrefslogtreecommitdiffstats
path: root/Dapp-Development.md
blob: 600c67d4b4264ade8bf741641d3adde70dc39381 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Currently, DEXON uses Ethereum's virtual machine (EVM) as the default VM. So Dapp development on DEXON is exactly the same as on Ethereum. An exception is that if you want to use DEXON's [on-chain random oracle](https://github.com/dexon-foundation/wiki/wiki/On-Chain-Random-Oracle).

DEXON's fork of solidity (called [dsolidity](https://github.com/dexon-foundation/dsolidity)) supports a special built-in variable called `rand`. Here is an example of how to use it:

```
contract Rand {
    uint256 value;

    function update() public {
        value = rand;
    }

    function get() view public returns (uint256) {
        return value;
    }
}
```

This very simple contract demonastrate how to use the `rand` variable. When `update()` is called, the state `value` is assigned to a random value generated by DEXON's on-chain random oracle.

To compile the contract, you will need to use [dsolidity](https://github.com/dexon-foundation/dsolidity). The nodejs version can also be found [here](https://github.com/dexon-foundation/dsolc-js).

Plan is on-going to allow truffle to support `dsolc-js`. For now, you can simply

1. Use truffle to develop your app
2. Replace the random variable with `rand`
3. Use `dsol-js` to compile the final byte-code
4. Deploy onto the DEXON network with myetherwallet or any other tools.