Swanky node is a Substrate based blockchain configured to enable pallet-contracts
(a smart contract module) and more features to help WASM smart contract development locally.
- pallet-contracts (polkadot-0.9.29) and its unstable-feature are enabled by default.
grandpa
&aura
consensus were removed. Instead,instant-seal
&manual-seal
are used. Blocks are authored (1) as soon as a transaction get in the pool (2) whenengine_createBlock
RPC called. Blocks are finalized whenengine_finalizeBlock
RPC called.- pallet-dapps-staking and ChainExtension to interact with it.
- pallet-assets.
- pallet-rmrk (core, equip, market) and chain extensions for pallet-rmrk-core.
It is optimized to local development purpose while removing unnecessary components such as P2P. More features and pallets to interact with (Contract <-> Runtime) will be added.
ink! version 3.3.1
or lower is supported by pallet-contract polkadot-0.9.29 branch.
The easiest way is to download a binary release from Release Page
First, complete the basic Rust setup instructions. After that, you can build node via
cargo build --release
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/swanky-node -h
This command will start the single-node development chain with persistent state.
./target/release/swanky-node
If you want to run the node with non-persist mode, use tmp option.
./target/release/swanky-node --tmp
# or
./target/release/swanky-node --dev
Purge the development chain's state.
./target/release/swanky-node purge-chain
Development alice account will be authority and sudo account as declared in the genesis state. At the same time the following accounts will be pre-funded:
- Alice
- Bob
- Charlie
- Dave
- Eve
- Ferdie
- Alice//stash
- Bob//stash
- Charlie//stash
- Dave//stash
- Eve//stash
- Ferdie//stash
To have only errors and contract debug output show up on the console you can supply
-lerror,runtime::contracts=debug
when starting the node.
Important: Debug output is only printed for RPC calls or off-chain tests ‒ not for transactions.
See ink! FAQ for more details: How do I print something to the console from the runtime?.
Once the swanky node is running locally, you can connect it with Polkadot-JS Apps front-end to interact with your chain. Click here connecting the Apps to your local swanky node.
First, install Docker and Docker Compose.
Then run the following command to start a single node development chain.
mkdir .local # this is mounted by container
./scripts/docker_run.sh
This command will firstly compile your code, and then start a local development network. You can
also replace the default command
(cargo build --release && ./target/release/swanky-node --dev --ws-external
)
by appending your own. A few useful ones are as follow.
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/swanky-node --ws-external
# Purge the local dev chain
./scripts/docker_run.sh ./target/release/swanky-node purge-chain
# Check whether the code is compilable
./scripts/docker_run.sh cargo check
Unlike other blockchains, Swanky node adopts block authioring and finalized gadget called Manual Seal and Instant Seal, consensus which is suitable for contracts development and testing.
Manual seal - Blocks are authored whenever RPC called. Instant seal - Block are authored as soon as transactions get inside the pool, most often one transaction per block.
Swanky node enables both Manual seal and Instant seal.
We can tell the node to author a block by calling the engine_createBlock
RPC.
$ curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d '{
"jsonrpc":"2.0",
"id":1,
"method":"engine_createBlock",
"params": [true, false, null]
}'
-
Create Empty
create_empty
is a Boolean value indicating whether empty blocks may be created. Settingcreate-empty
to true does not mean that an empty block will necessarily be created. Rather it means that the engine should go ahead creating a block even if no transaction are present. If transactions are present in the queue, they will be included regardless ofcreate_empty
's value.' -
Finalize
finalize
is a Boolean indicating whether the block (and its ancestors, recursively) should be finalized after creation. -
Parent Hash
parent_hash
is an optional hash of a block to use as a parent. To set the parent, use the format"0x0e0626477621754200486f323e3858cd5f28fcbe52c69b2581aecb622e384764"
. To omit the parent, usenull
. When the parent is omitted the block is built on the current best block. Manually specifying the parent is useful for constructing fork scenarios and demonstrating chain reorganizations.
In addition to finalizing blocks while creating them, they can be finalized later by using the second provided RPC call, engine_finalizeBlock
.
$ curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d '{
"jsonrpc":"2.0",
"id":1,
"method":"engine_finalizeBlock",
"params": ["0x0e0626477621754200486f323e3858cd5f28fcbe52c69b2581aecb622e384764", null]
}'