For development purposes, it is convenient to set up a local Ethereum client with a group of connected peers. A note-taken walkthrough set up local T network covers the entire process including setting up a local Ethereum client, deploying T contracts and configuring T peers.
Additionally, to start a client we need to provide configuration options. It is
required to create a config file under /configs
for each client. You can also
overwrite the existing config file by passing supported parameters. For simple
installation using a config file please refer to the
configuration section.
The ./scripts/install.sh
needs to be run only once and it will:
-
install yarn dependencies across the projects
-
unlock ethereum accounts
-
build
threshold-network/solidity-contracts
,random-beacon
,ecdsa
andtbtc-v2
contracts -
deploy
threshold-network/solidity-contracts
,random-beacon
,ecdsa
andtbtc-v2
contracts -
build a client
For more info please refer to ./scripts/install.sh --help
Usage:
ENV_VAR(S) ./scripts/install.sh \
--network <network> \
--tbtc-path <tbtc-path> \
--threshold-network-path <threshold-network-path> \
--skip-deployment \
--skip-client-build
Environment variables:
KEEP_ETHEREUM_PASSWORD: The password to unlock local Ethereum accounts to set up delegations. Required only for 'local' network. Default value is 'password'
Optional line arguments:
--network: Ethereum network for keep-core client(s). Available networks and settings are specified in the 'hardhat.config.ts'
--tbtc-path: 'Local' tbtc project's path. 'tbtc' is cloned to a temporary directory upon installation if the path is not provided
--threshold-network-path: 'Local' threshold network project's path. 'threshold-network/solidity-contracts' is cloned to a temporary directory upon installation if the path is not provided
--skip-deployment: This option skips all the contracts deployment. Default is false
--skip-client-build: Should execute contracts part only. Client installation will not be executed
The ./scripts/initialize.sh
has to be run for each client instance you wish to
start.
If the --stake-owner <address>
is not set, then it will prompt you to select a
configuration file that will be used to fetch the stake owner’s address from.
Default setup assumes that the staking provider, operator, beneficiary, and the
authorizer all have the same addresses as the stake owner. Only the stake-owner
has to be unique for the default setup. The default stake amount is 1,000,000 T
tokens. The default authorization amount is the minimum authorization amount.
Ex. if you need to initialize a network with 3 clients using the default setup, then this script needs to be run 3 times with a different selected config file like so:
./scripts/initialize.sh
Select client config file:
1) config.toml <--
2) config1.toml
3) config2.toml
./scripts/initialize.sh
Select client config file:
1) config.toml
2) config1.toml <--
3) config2.toml
./scripts/initialize.sh
Select client config file:
1) config.toml
2) config1.toml
3) config2.toml <--
The ./scripts/initialize.sh
script will:
-
mint & approve
T
tokens -
stake
T
tokens -
increase authorization for
RandomBeacon
andWalletRegistry
applications -
register operator for
RandomBeacon
andWalletRegistry
applications
For more info please refer to ./scripts/initialize.sh --help
Usage:
./scripts/initialize.sh \
--network <network> \
--stake-owner <stake owner address> \
--staking-provider <staking provider address> \
--operator <operator address> \
--beneficiary <beneficiary address> \
--authorizer <authorizer address> \
--stake-amount <stake amount> \
--authorization-amount <authorization amount>
Optional line arguments:
--network: Ethereum network for keep-core client. Available networks and settings are specified in the 'hardhat.config.ts'
--stake-owner: Stake owner address
--staking-provider: Staking provider address
--operator: Operator address
--beneficiary: Staking beneficiary address
--authorizer: Staking authorizer address
--stake-amount: Stake amount
--authorization-amount: Authorization amount
Afer executing ./scripts/install.sh
and ./scripts/initialize.sh
now you can
run ./scripts/start.sh
to start a client. It will prompt you to chose from the
available config files (that should match the one chosen for
./scripts/initialize.sh
) and the log level.
./scripts/start.sh
Select client config file:
1) config.toml <--
2) config1.toml
3) config2.toml
1
Select log level [info]:
1) info
2) debug
3) custom...
./scripts/start.sh
Select client config file:
1) config.toml
2) config1.toml <--
3) config2.toml
2
Select log level [info]:
1) info
2) debug
3) custom...
./scripts/start.sh
Select client config file:
1) config.toml
2) config1.toml
3) config2.toml <--
3
Select log level [info]:
1) info
2) debug
3) custom...
Please refer to
./scripts/start.sh --help
for more info
./scripts/start.sh --help
Usage: ENV_VAR(S) ./scripts/start.sh --config-dir <path-to-configuration-files>
Environment variables:
KEEP_ETHEREUM_PASSWORD: Ethereum account password. Required only for 'local' network. Default value is 'password'
Command line arguments:
--config-dir: Path to a client configuration files
There are two primary languages in the T code right now:
- Go
-
Go code largely adheres to community practices where they have been decided. Divergences and additional tidbits are listed in the Go Guidelines document.
- Solidity
-
Solidity code generally adheres to the Solidity style guide. Contracts and their functions are documented using the Ethereum Natural Specification Format (NatSpec).
The fastest and easiest way to have a local Ethereum testent is to use Hardhat.
Navigate to one of the projects solidity/ecdsa
or solidity/random-beacon
.
You can deploy contracts executing yarn deploy
or run tests against the local
Hardhat’s network yarn test
.