/icetea

A smart contract & decentralized bot engine, with a focus on usability and developer-friendly.

Primary LanguageJavaScriptMIT LicenseMIT

ICETEA

Build Status GitHub commit activity Dependencies Dev Dependencies License

js-standard-style

Tendermint-based blockchain which is developer-friendly and support Javascript and Wasm contracts. There's more to come, stay tune!

NOTE: this project is under active development. Don't use it for production.

Presequisite

  1. NodeJS v11.8 or above
  2. Tendermint latest release
  3. tendermint init

Open ~/.tendermint/config/config.toml.

Search for index_tags and comment that line out (i.e. add # to the beginning of that line).

# index_tags = ...

Then search for and set index_all_tags to true.

index_all_tags = true

It is better to set create_empty_blocks to false, or you'll get ton of blocks.

create_empty_blocks = false

Setup

  1. clone repo
  2. Rename .env.example to .env and .env.dev.example to .env.dev
  3. npm install
  4. tendermint node
  5. Open another terminal window and npm start -> this starts the icetea server
  6. Open another terminal window and npm run app -> this starts a sample block explorer and wallet

To reset tendermint (delete all blocks & state), use npm run reset.

Sample contracts

@contract class Withdraw {
    @state fund = {}

    @onreceive @payable receive() {
        this.fund[msg.sender] = (this.fund[msg.sender] || 0) + msg.value
    }

    @transaction withdraw() {
        const available = this.fund[msg.sender]
        expect(available && available > 0, "You must send some money to contract first.")
        expect(this.balance > 0, "Contract out of money, please come back later.")

        const amount = available < this.balance ? available : this.balance
        this.fund[msg.sender] = available - amount

        this.transfer(msg.sender, amount)
        this.emitEvent("Withdrawn", { withdrawer: msg.sender, amount })
    }

    @transaction backdoor(value: ?number = this.balance) {
        expect(msg.sender === this.deployedBy, "Only owner can use this backdoor.")
        this.transfer(msg.sender, value)
    }
}

More sample contracts are available in example folder.

Check out our guide here https://github.com/TradaTech/icetea/wiki/Javascript-smart-contract