<commit_before># Bamboo 0.0.01 Tutorial

This document covers
* installation of the Bamboo compiler
* compilation and deployment of a Bamboo program
* interaction with the deployed Ethereum contract

## Installing the Bamboo compiler

The Bamboo compiler can be installed with the OCaml package manager `opam`.

If you don't have it yet, get `opam` by
* `apt-get install opam`
* `brew install opam`
* or one of [many other ways](https://opam.ocaml.org/doc/Install.html)

After installing `opam`, run `opam init` and follow the instructions.

When `opam` is ready, `opam install bamboo` gets you the Bamboo compiler.

```
$ bamboo --version
0.0.01
```

If anything goes wrong, poke @pirapira on [the Gitter channel](https://gitter.im/bbo-dev).

## Compiling Bamboo code

Let's deploy [this ERC20 contract](https://github.com/pirapira/bamboo/blob/master/src/parse/examples/01b_erc20better.bbo) on the Ropsten test network.

```
wget https://raw.githubusercontent.com/pirapira/bamboo/master/src/parse/examples/01b_erc20better.bbo
```
will get you a file `01b_erc20better.bbo`.  You can have a look now, but I'll explain the contents when we interact with the contract.

Now,
```
bamboo < 01b_erc20better.bbo > compiled.hex
```
should store something in `compiled.hex` file.  You can have a look.  If you use it for anything serious, you should investigate `compiled.hex` here.  Since we are just playing on the test network, we go ahead deploying the compiled code.

Also,
```
bamboo --abi < 01b_erc20better.bbo > abi.json
```
will get you a JSON file `abi.json` that describes the interface of this Ethereum contract.

## Deploying on the Ropsten test network

The Ropsten network is a test network for Ethereum.  The balances and accounts are cleared sometimes.  In this tutorial we deploy the code to Ropsten.

### Connecting go-ethereum to the Ropsten network

We use `go-ethereum`.  [Install go-ethereum](https://ethereum.github.io/go-ethereum/install/) somehow and run
```
build/bin/geth console --testnet --fast --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@192.168.3.11:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@192.168.3.11:30303"
```

When you are still seeing something like
```
INFO [08-02|14:00:28] Imported new chain segment               blocks=119 txs=324 mgas=130.952 elapsed=8.008s    mgasps=16.352 number=1375400 hash=cd3c3f…a39ed3
```
with `blocks=119` or some big numbers, `go-ethereum` has not synced yet.

When it's synced, you will be seeing `blocks=1`
```
INFO [08-02|14:22:16] Imported new chain segment               blocks=1    txs=0    mgas=0.000   elapsed=13.958ms  mgasps=0.000   number=1417137 hash=8603a5…1de724<commit_msg>Add $s before shell commands<commit_after># Bamboo 0.0.01 Tutorial

This document covers
* installation of the Bamboo compiler
* compilation and deployment of a Bamboo program
* interaction with the deployed Ethereum contract

## Installing the Bamboo compiler

The Bamboo compiler can be installed with the OCaml package manager `opam`.

If you don't have it yet, get `opam` by
* `apt-get install opam`
* `brew install opam`
* or one of [many other ways](https://opam.ocaml.org/doc/Install.html)

After installing `opam`, run `opam init` and follow the instructions.

When `opam` is ready, `opam install bamboo` gets you the Bamboo compiler.

```
$ bamboo --version
0.0.01
```

If anything goes wrong, poke @pirapira on [the Gitter channel](https://gitter.im/bbo-dev).

## Compiling Bamboo code

Let's deploy [this ERC20 contract](https://github.com/pirapira/bamboo/blob/master/src/parse/examples/01b_erc20better.bbo) on the Ropsten test network.

```
$ wget https://raw.githubusercontent.com/pirapira/bamboo/master/src/parse/examples/01b_erc20better.bbo
```
will get you a file `01b_erc20better.bbo`.  You can have a look now, but I'll explain the contents when we interact with the contract.

Now,
```
$ bamboo < 01b_erc20better.bbo > compiled.hex
```
should store something in `compiled.hex` file.  You can have a look.  If you use it for anything serious, you should investigate `compiled.hex` here.  Since we are just playing on the test network, we go ahead deploying the compiled code.

Also,
```
$ bamboo --abi < 01b_erc20better.bbo > abi.json
```
will get you a JSON file `abi.json` that describes the interface of this Ethereum contract.

## Deploying on the Ropsten test network

The Ropsten network is a test network for Ethereum.  The balances and accounts are cleared sometimes.  In this tutorial we deploy the code to Ropsten.

### Connecting go-ethereum to the Ropsten network

We use `go-ethereum`.  [Install go-ethereum](https://ethereum.github.io/go-ethereum/install/) somehow and run
```
$ build/bin/geth console --testnet --fast --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@192.168.3.11:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@192.168.3.11:30303"
```

When you are still seeing something like
```
INFO [08-02|14:00:28] Imported new chain segment               blocks=119 txs=324 mgas=130.952 elapsed=8.008s    mgasps=16.352 number=1375400 hash=cd3c3f…a39ed3
```
with `blocks=119` or some big numbers, `go-ethereum` has not synced yet.

When it's synced, you will be seeing `blocks=1`
```
INFO [08-02|14:22:16] Imported new chain segment               blocks=1    txs=0    mgas=0.000   elapsed=13.958ms  mgasps=0.000   number=1417137 hash=8603a5…1de724
{'fraction_non_alphanumeric': 0.0974037288726259, 'fraction_numerical': 0.10629029447638962, 'mean_word_length': 4.644051130776795, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2681012', 'n_tokens_mistral': 2416, 'n_tokens_neox': 2011, 'n_words': 605}