|
| 1 | + |
| 2 | +# Integrating systems with Open Libra |
| 3 | + |
| 4 | +Open Libra provides containers with signed pre-built `libra` binary which starts nodes and sends transactions. |
| 5 | + |
| 6 | +The default instructions assumes you are using container tools like docker, kubernetes, podman etc. |
| 7 | + |
| 8 | +Below we include instructions for building from source. |
| 9 | + |
| 10 | +# Run a container fullnode |
| 11 | + |
| 12 | +Instructions for running a fullnode with docker etc. can be found at: https://github.com/0LNetworkCommunity/libra-framework/blob/main/container/README.md |
| 13 | + |
| 14 | +# Execute transactions with `libra` binary |
| 15 | +The `libra` cli binary for running the node, also includes subcommands for executing transactions. |
| 16 | +[More info:](docs/cli-tools/txs/transfer.md) |
| 17 | + |
| 18 | +## Optionally use NodeJS sdk |
| 19 | +The NodeJS typescript SDK is available for integrators. This library is NOT included in the container environment. |
| 20 | +NPM package: https://www.npmjs.com/package/open-libra-sdk |
| 21 | + |
| 22 | +# Testing your integration |
| 23 | +Testnets on Open Libra are configured exactly as in production. As such there are no special features (such as faucets). |
| 24 | +To simulate transactions (e.g. create other accounts), you can load a wallet with predefined test mnemonics. These personas, alice, bob, carol, are the genesis validators of the testnets. |
| 25 | + |
| 26 | +### Test accounts |
| 27 | +#### Alice |
| 28 | +address: `0x87515d94a244235a1433d7117bc0cb154c613c2f4b1e67ca8d98a542ee3f59f5` |
| 29 | + |
| 30 | +mnemonic: `talent sunset lizard pill fame nuclear spy noodle basket okay critic grow sleep legend hurry pitch blanket clerk impose rough degree sock insane purse` |
| 31 | + |
| 32 | +## Open Libra Testnet |
| 33 | + |
| 34 | +A testnet API service can be accessed at: `http://testnet.openlibra.io:8080/v1`. Note the state resets every week. There is no faucet on OL testnets (we use production settings). You should use the default genesis test accounts (Alice, Bob, Carol) as described here. |
| 35 | + |
| 36 | +Note that the chain id for the chain_name `TESTNET` is `2`. If you submit mainnet (id `1`) against this URL, transactions will be rejected. |
| 37 | + |
| 38 | +## Start a local testnet |
| 39 | + |
| 40 | +Using `docker compose` or equivalent you can start a containerized testnet of three nodes. |
| 41 | +``` |
| 42 | +Checkout the files at: |
| 43 | +https://github.com/0LNetworkCommunity/libra-framework/tree/main/container |
| 44 | +
|
| 45 | +# Start the testnet |
| 46 | +docker up compose.yaml -d |
| 47 | +
|
| 48 | +# wait about one minute, then the API from node-1 (alice) will respond |
| 49 | +curl localhost:8280/v1 |
| 50 | +``` |
| 51 | +### Connect to local testnet with client |
| 52 | + |
| 53 | +### using `libra` cli |
| 54 | +Update the $HOME/.libra/cli config |
| 55 | +``` |
| 56 | +# Interactive tool: configure tools, enter the mnemonic above |
| 57 | +libra config init |
| 58 | +libra config --profile my-testnet fix --force-url localhost:8280/v1 |
| 59 | +``` |
| 60 | + |
| 61 | +Optionally for automated testing these envvars for non-interactive mode: |
| 62 | + |
| 63 | +``` |
| 64 | +export LIBRA_CI=1 |
| 65 | +# obviously don't do this in production |
| 66 | +export MNEM=<your mnemonic> |
| 67 | +``` |
| 68 | + |
| 69 | +### Using typescript sdk |
| 70 | + |
| 71 | +``` |
| 72 | + import { Libra } from 'open-libra-sdk' |
| 73 | + // get the mainnet fullnode |
| 74 | + const libra = new Libra(); |
| 75 | +
|
| 76 | + // optionally connect to a local testnet |
| 77 | + const libra = new Libra(Network.TESTNET, 'localhost:8480/v1'); |
| 78 | +
|
| 79 | + const ledgerInfo = await libra.getLedgerInfo(); |
| 80 | +``` |
| 81 | + |
| 82 | +## Optionally Build Source |
| 83 | +Instead of using the published container image you may choose to build from source. This assumes you have Rust installed on the `stable` channel. |
| 84 | + |
| 85 | +``` |
| 86 | +git clone https://github.com/0LNetworkCommunity/libra-framework |
| 87 | +cd libra-framework |
| 88 | +
|
| 89 | +rust build --release -p libra |
| 90 | +
|
| 91 | +# Copy the binary to where you need it |
| 92 | +cp ./target/release/libra $HOME/.cargo/bin |
| 93 | +
|
| 94 | +``` |
0 commit comments