Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loomnetwork/loom-truffle-provider
Adapter that allows Truffle Suite to communicate with Loom DappChain
https://github.com/loomnetwork/loom-truffle-provider
Last synced: about 1 month ago
JSON representation
Adapter that allows Truffle Suite to communicate with Loom DappChain
- Host: GitHub
- URL: https://github.com/loomnetwork/loom-truffle-provider
- Owner: loomnetwork
- License: bsd-3-clause
- Created: 2018-06-04T10:58:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T19:40:04.000Z (about 2 years ago)
- Last Synced: 2023-02-28T07:02:59.878Z (almost 2 years ago)
- Language: TypeScript
- Size: 787 KB
- Stars: 28
- Watchers: 6
- Forks: 9
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Loom Truffle Provider
Adapter that allows `Truffle Suite` to communicate with a `Loom DappChain`.
## Install
```bash
yarn add loom-truffle-provider
# or
npm install loom-truffle-provider
```## Requirements
```
Node >= 8
```## Truffle
```
npm install -g truffle
```## Description
Loom Truffle Provider makes it possible to deploy smart contracts written in Solidity and using Truffle Suite on a Loom
DappChain. Here's an example Truffle configuration that uses the Loom Truffle Provider...```javascript
// truffle.js
const { readFileSync } = require('fs')
const LoomTruffleProvider = require('loom-truffle-provider')const chainId = 'default'
const writeUrl = 'http://127.0.0.1:46658/rpc'
const readUrl = 'http://127.0.0.1:46658/eth'// ./privateKey file contains a base64 encoded key generated by the command:
// loom genkey -a publicKey -k privateKey
const privateKey = readFileSync('./privateKey', 'utf-8')const loomTruffleProvider = new LoomTruffleProvider(chainId, writeUrl, readUrl, privateKey)
// Create 10 extra accounts, useful for tests
loomTruffleProvider.createExtraAccounts(10)module.exports = {
networks: {
loom_dapp_chain: {
provider: loomTruffleProvider,
network_id: '*'
}
}
};
```### Accounts managed by LoomTruffleProvider
In order to access accounts on `LoomTruffleProvider` you should use the function `getProviderEngine`
which will return the `LoomProvider` giving access to properties `accounts`.```Javascript
const loomTruffleProvider = new LoomTruffleProvider(chainId, writeUrl, readUrl, privateKey)
const loomProvider = loomTruffleProvider.getProviderEngine()console.log("Accounts and Private Keys", loomProvider.accounts)
```Another way to create extra accounts is to use a `BIP-39 mnemonic`, which will create extra accounts
from a set of words.```Javascript
// Using the mnemonic code to create 10 accounts
loomTruffleProvider.createExtraAccountsFromMnemonic("gravity top burden ship student car spell purchase hundred improve check genre", 10)
```Note that the account at index `0` is created from the key passed to the `LoomTruffleProvider` constructor,
while the other accounts are created from the `mnemonic`.## Notes
* Make sure that the `Loom DappChain` node is running before executing any `Truffle` command.
* The `Truffle` `network` option must be set to `loom_dapp_chain` when using the example configuration
above, e.g. `truffle deploy --network loom_dapp_chain`.