Ethereum - Ganache(가나쉬)
2023. 5. 26. 21:50ㆍBlockChain/Ethereum
목차 |
1. Ganache(가나쉬) |
1. Ganache(가나쉬)
가나쉬는 이더리움 블록체인 네트워크를 로컬 환경에서 시뮬레이션하고 개발 및 테스트 하는데 사용되는 개발 도구이다.
간단하게 요약해보자면 가나쉬는 간편하게 사용할 수 있는 이더리움 네트워크(서버)라고 생각하면된다.
실제 이더리움 서버를 이용하기에는 비용이 들기도 하고 시간도 오래 걸린다.
이는 개발하는데에 있어서 상당히 비효율적이다. 이를 해소하기 위해 가나쉬라는 것을 사용한다.
가나쉬는 GUI 환경에서도 사용할 수 있고, CLI 환경에서 사용할 수도 있다.
아래의 사이트에서 설치 후 GUI 환경을 사용할 수 있다.
https://trufflesuite.com/ganache/
Ganache - Truffle Suite
Features VISUAL MNEMONIC & ACCOUNT INFO Quickly see the current status of all accounts, including their addresses, private keys, transactions and balances.
trufflesuite.com
아래는 CLI 환경에서 사용할 수 있도록 설치하는 명령어 이다(npm 패키지 기준)
npx ganache-cli
npm install ganache-cli
npm install -g ganache-cli // 글로벌 환경 설치
아래는 ganache --help를 입력하면 나오는 옵션들이니 필요에 따라서 옵션 설정을 해주도록하자.
ex) 윈도우에서 가상머신을 실행하는 경우 host를 바꿔줄 때 등등
Network:
-p, --port Port number to listen on [number] [default: 8545]
-h, --host, --hostname Hostname to listen on [string] [default: "127.0.0.1"]
--keepAliveTimeout The number of milliseconds of inactivity a server needs
to wait for additional incoming data, after it has
finished writing the last response, before a socket will
be destroyed. [number] [default: 5000]
Accounts:
-a, --accounts Number of accounts to generate at startup
[number] [default: 10]
-e, --defaultBalanceEther Amount of ether to assign each test account
[number] [default: 100]
--account Account data in the form
'<private_key>,<initial_balance>', can be
specified multiple times. Note that private
keys are 64 characters long and must be entered
as an 0x-prefixed hex string. Balance can
either be input as an integer, or as a
0x-prefixed hex string with either form
specifying the initial balance in wei. [array]
--account_keys_path, --acctKeys saves generated accounts and private keys as
JSON object in specified file
[string] [default: null]
-n, --secure Lock available accounts by default (good for
third party transaction signing)
[boolean] [default: false]
-u, --unlock Comma-separated list of accounts or indices to
unlock [array]
--hdPath, --hd_path The hierarchical deterministic path to use when
generating accounts. Default: "m/44'/60'/0'/0/"
[string]
Chain:
-k, --hardfork Allows users to specify which hardfork should be
used. Supported hardforks are `byzantium`,
`constantinople`, `petersburg`, `istanbul` and
`muirGlacier` (default).
[string] [default: "muirGlacier"]
-f, --fork Fork from another currently running Ethereum
client at a given block. Input should be the HTTP
location and port of the other client, e.g.
'http://localhost:8545' or optionally provide a
block number 'http://localhost:8545@1599200'
[string] [default: false]
--forkCacheSize The maximum size, in bytes, of the in-memory cache
for queries on a chain fork. Defaults to
`1_073_741_824` bytes (1 gigabyte). You can set
this to `0` to disable caching (not recommended),
or to `-1` for unlimited (will be limited by your
node process). [number] [default: 1073741824]
--db Directory of chain database; creates one if it
doesn't exist [string] [default: null]
-s, --seed Arbitrary data to generate the HD wallet mnemonic
to be used
[string] [default: Random value, unless -d is specified]
-d, --deterministic Generate deterministic addresses based on a
pre-defined mnemonic. [boolean]
-m, --mnemonic bip39 mnemonic phrase for generating a PRNG seed,
which is in turn used for hierarchical
deterministic (HD) account generation [string]
--noVMErrorsOnRPCResponse Do not transmit transaction failures as RPC
errors. Enable this flag for error reporting
behaviour which is compatible with other clients
such as geth and Parity.[boolean] [default: false]
-b, --blockTime Block time in seconds for automatic mining. Will
instantly mine a new block for every transaction
if option omitted. Avoid using unless your test
cases require a specific mining interval. [number]
-i, --networkId The Network ID ganache-cli will use to identify
itself.
[number] [default: System time at process start or Network ID of forked
blockchain if configured.]
--chainId The Chain ID ganache-cli will use for
`eth_chainId` RPC and the `CHAINID` opcode.
[number] [default: For legacy reasons, the default is currently `1337` for
`eth_chainId` RPC and `1` for the `CHAINID` opcode. This will be fixed in the
next major version of ganache-cli and ganache-core!]
-g, --gasPrice The price of gas in wei
[number] [default: 20000000000]
-l, --gasLimit The block gas limit in wei
[number] [default: 6721975]
--callGasLimit Sets the transaction gas limit for `eth_call` and
`eth_estimateGas` calls. Must be specified as a
hex string. Defaults to "0x1fffffffffffff"
(Number.MAX_SAFE_INTEGER)
[number] [default: 9007199254740991]
--allowUnlimitedContractSize Allows unlimited contract sizes while debugging.
By enabling this flag, the check within the EVM
for contract size limit of 24KB (see EIP-170) is
bypassed. Enabling this flag *will* cause
ganache-cli to behave differently than production
environments. [boolean] [default: false]
-t, --time Date (ISO 8601) that the first block should start.
Use this feature, along with the evm_increaseTime
method to test time-dependent code. [string]
Other:
--debug Output VM opcodes for debugging [boolean] [default: false]
-v, --verbose Log all requests and responses to stdout
[boolean] [default: false]
--mem Only show memory output, not tx history[boolean] [default: false]
-q, --quiet Run ganache quietly (no logs) [boolean] [default: false]
Options:
--help, -? Show help [boolean]
--version Show version number [boolean]
'BlockChain > Ethereum' 카테고리의 다른 글
Ethereum - Truffle (0) | 2023.05.27 |
---|---|
Ethereum - Smart Contract(스마트 컨트랙트, 계약) (0) | 2023.05.27 |
Ethereum - EVM(Ethereum Virtual Machine)와 가스(Gas) (0) | 2023.05.27 |
Ethereum과 Web3 (0) | 2023.05.25 |
Ethereum - 이더리움 (0) | 2023.05.25 |