This demo shows of how to use Godwoken.
The demo provides the following functionalities:
- Deposit from a MetaMask powered address into Godwoken.
- Deploy an Ethereum Smart Contract to Polyjuice running on Godwoken, we use SimpleStorage.
- Submit a polyjuice transaction to set the value in SimpleStorage smart contract.
- Execute (but do not submit) a transaction to fetch the current stored value in SimpleStorage smart contract.
- Query the balance of a Godwoken account.
- Make transfers between Godwoken accounts.
- Withdraw from Godwoken back to a layer 1 CKB address.
yarn run bootstrap
Firstly copy config files.
cp <your godwoken `scripts-deploy-result.json`> packages/demo/src/configs/scripts-deploy-result.json
cp <your godwoken `config.toml`> packages/demo/src/configs/godwoken-config.json (convert config.toml to json format)
cp packages/demo/src/configs/config.json.sample packages/demo/src/configs/config.json
# then update `config.json` with your own config.
Deposit CLI both support testnet
and dev chain
.
yarn workspace @godwoken-examples/godwoken tsc
yarn workspace @godwoken-examples/demo clean-cli && yarn workspace @godwoken-examples/demo build-cli
Run deposit.js --help
to see how to use this command.
LUMOS_CONFIG_FILE=<your lumos config json file> node ./packages/demo/build-cli/cli/deposit.js --help
Or Deposit SUDT
LUMOS_CONFIG_FILE=<your lumos config json file> node ./packages/demo/build-cli/cli/deposit_sudt.js --help
Deposit and Deposit SUDT module only support testnet
, other parts support both testnet
and dev chain
yarn workspace @godwoken-examples/godwoken tsc
yarn workspace @godwoken-examples/demo clean && yarn workspace @godwoken-examples/demo build
yarn workspace @godwoken-examples/demo start
Open http://localhost:9000/html/index.html
Run godwoken-cli.js --help
to see how to use this command.
yarn workspace @godwoken-examples/godwoken tsc
yarn workspace @godwoken-examples/tools tsc
LUMOS_CONFIG_FILE=<your lumos config json file> node ./packages/tools/lib/godwoken-cli.js unlockWithdraw --help
yarn workspace @godwoken-examples/godwoken tsc
yarn workspace @godwoken-examples/polyjuice tsc
yarn workspace @godwoken-examples/tools tsc
Create account id for create polyjuice contract account (the creator_account_id
config)
$ node packages/tools/lib/polyjuice-cli.js createCreatorAccount <from_id> <sudt_id> <rollup_type_hash> <privkey>
You can see <rollup_type_hash>
when godwoken started.
<sudt_id>
given 1
is for CKB Token.
<privkey>
is a 0x
prefixed hex string.
<from_id>
is your user account, you can get the account id by:
$ node packages/tools/lib/godwoken-cli.js getAccountIdByScriptHash <script_hash>
You can get the script hash when deposition finished.
polyjuice-cli.js createCreatorAccount
will return an creator_account_id
and write this to packages/demo/src/configs/config.json
creator_account_ids
.
And recompile demo
yarn workspace @godwoken-examples/demo clean && yarn workspace @godwoken-examples/demo build
Also supported by Demo Page.
$ node packages/tools/lib/polyjuice-cli.js deploy <creator_account_id> <init_code> <rollup_type_hash> <privkey>
This will output the account id.
The <init_code>
sample, please see SimpleStorage.bin .
Also supported by Demo Page.
$ node packages/tools/lib/polyjuice-cli.js call <to_id> <input_data> <rollup_type_hash> <privkey>
<to_id>
is the account created in deploy step.
The <input_data>
is generated by ethabi , please see SimpleStorage.calls.md .