Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pooltogether/oz-console
https://github.com/pooltogether/oz-console
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pooltogether/oz-console
- Owner: pooltogether
- Created: 2019-10-29T01:20:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T00:44:06.000Z (almost 2 years ago)
- Last Synced: 2024-04-29T19:06:22.261Z (8 months ago)
- Language: JavaScript
- Size: 525 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenZeppelin Ethers Console
Provides an Ethers.js based console to interact with your contracts.
## Installation
```bash
$ yarn add oz-console
```## Usage
`oz-console` can be used from the command line or programmatically.
For example: let's assume you have an ERC20 called MyToken that is deployed to mainnet.
Let's interact with the contract:
```bash
# Contracts should be deployed and compiled
$ oz-console -n mainnet
```Now we're in `oz-console`:
```javascript
// contracts contains Ethers.js Contract instance of all deployed contracts
mainnet> await contracts.MyToken.totalSupply()
// await here is redundant, but demonstrates that the syntax is supported
```Or get the ether balance:
```javascript
// provider and contracts are available in the environment
mainnet> provider.getBalance(contracts.MyToken.address)
```Create contracts on-the-fly:
```javascript
// ethers, signers, and artifacts are available in the enviroment
mainnet> let MyToken2 = new ethers.Contract('0x1234...', artifacts.MyToken.abi, signer)
```For a complete reference of what variables are available in the global context see below.
### CLI Help
```
Usage: oz-console [options]Provides an Ethers.js based console to interact with your OpenZeppelin SDK project. Supports await syntax. Includes global variables:
artifacts: Every project contract discovered, including ProxyAdmin
interfaces: An Ethers interface for each artifact discovered
contracts: An Ethers contract for each *deployed* artifact. Includes ProxyAdmin.
provider: an ethers provider
signer: a signer for the configured OZ 'from' address
ethers: the ethers libOptions:
-n, --network selects the openzeppelin network to use (default: "mainnet")
-p, --projectConfig sets the project config path (default: ".openzeppelin/project.json")
-v, --verbose enable verbose logging. useful for diagnosing errors
-e, --exec executes a javascript file instead of running a REPL
-a, --address use the address as the signer
-h, --help shows this help```
## Programmatic Usage
Use `buildContext` to setup the environment programmatically
```javascript
const { buildContext } = require('oz-console')const context = buildContext({
network: 'mainnet'
})// Ethers
context.ethers
// OpenZeppelin CLI ProjectFile object
context.projectFile
// Artifact JSON blobs
context.artifacts
// Ethers Interfaces for each artifact
context.interfaces
// Ethers Contract for each deployed contract
context.contracts
// Ethers provider
context.provider
// Ethers signer for the OZ 'from' address
context.signer
// OpenZeppelin CLI NetworkFile object
context.networkFile
// OpenZeppelin CLi NetworkConfig object
context.networkConfig
```