https://github.com/simov/crypto-contract
Ethereum Contract Tool
https://github.com/simov/crypto-contract
Last synced: 8 months ago
JSON representation
Ethereum Contract Tool
- Host: GitHub
- URL: https://github.com/simov/crypto-contract
- Owner: simov
- License: mit
- Created: 2015-10-09T10:46:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-02T10:49:34.000Z (over 8 years ago)
- Last Synced: 2025-04-07T02:48:07.493Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ethereum Contract Tool
## Install
```bash
$ npm install -g @crypto/contract
```
## Command Line Options
```bash
# print all available options
$ contract -h
```
### Specify Contract File
```bash
# specify a contract file and enter prompt mode
$ contract -f
```
```bash
# additionally specify the RPC host and port
$ contract -h amazing.com -p 9999 -f
```
> If omitted host defaults to `localhost` and port defaults to `6767`.
## Prompt Options
### Compile
```bash
# compile the contract
contract$ compile
```
### Deploy
```bash
# deploy the contract
contract$ deploy
```
```bash
# additionally set the account address to use when deploying
contract$ deploy -a
```
> If omitted account address defaults to the first account `web3.eth.accounts[0]`.
```bash
# additionally set the gas amount to use when deploying
contract$ deploy -g
```
> If omitted the gas amount defaults to `1000000`.
### Init
```bash
# instantiate the contract
contract$ init -a
```
### Set Name
```bash
# set contract instance name
contract$ name
```
```bash
# enter interactive REPL mode
contract$
```
### Execute Methods
```bash
# execute contract specific methods
contract$ name: newDocument('hash', {from: web3.eth.coinbase, gas: 1800000})
```
### Watch for Events
```bash
# subscribe for specific event
contract$ notereth$ DocumentEvent({}, {fromBlock: 0, toBlock: 'latest'}).watch
```
```bash
# subscribe for all events
contract$ notereth$ allEvents({}, {fromBlock: 0, toBlock: 'latest'}).watch
```
## Example
### Basics
```bash
# specify contract file
$ contract -f
# deploy the contract using the first unlocked account
contract$ deploy
# set contract instance name
contract$ name notereth
# enter contract interactive REPL
contract$ notereth
# execute methods from that contract
notereth$ notereth: newDocument('hash', {from: web3.eth.coinbase, gas: 1800000})
```
### Watching
```bash
# instantiate the contract in two separate console windows at the same time
$ contract -f
contract$ init -a 0x241bbd0ef9492aa17866c662b750f24003c812c6
contract$ name notereth
contract$ notereth
contract$ notereth:
```
```bash
# set a watcher in the first console window
contract$ notereth$ DocumentEvent({}, {fromBlock: 0, toBlock: 'latest'}).watch
```
> Notice that the callback for the `watch` method is missing.
```bash
# execute some command in the second console window
contract$ notereth$ newDocument('hash', {from: web3.eth.coinbase, gas: 1800000})
```