Configuration
When running npx redspot
command, it will search for the closest redspot.config.ts
file from the current working directory, which is usually located in the root directory of the project. This file contains configuration for the entire Redspot, such as configuration, plug-ins, and custom tasks.
The entirety of your Redspot setup such tasks, plugins, network and other configs is configured through this file.
#
Configuration optionsTo set the configuration, you need to export the object from redspot.config.ts
.
import { RedspotUserConfig } from 'redspot/types';export default { defaultNetwork: 'development', contract: { ink: { toolchain: 'nightly', sources: ['contracts/**/*'] }, solang: { sources: ['contracts/**/*.sol'] } }, networks: { development: { endpoint: 'ws://127.0.0.1:9944', types: {}, gasLimit: '400000000000' }, substrate: { endpoint: 'ws://127.0.0.1:9944', gasLimit: '400000000000', accounts: ['//Alice', "tomato mad peasant blush poem obtain inspire distance attitude mercy return marriage", "0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"], types: {} } }, paths: { artifacts: "artifacts", tests: "tests" }, mocha: { timeout: 60000 }} as RedspotUserConfig;
#
defaultNetworkYou can define the network used by default when running Redspot through the defaultNetwork field in the configuration. If this configuration is omitted, its default value is localhost.
#
networksThe networks configuration field is an optional object, and the network name is mapped to its configuration. The configuration information of the default localhost is as follows.
{ localhost: { gasLimit: "400000000000", accounts: ["//Alice", "//Bob", "//Charlie", "//Dave", "//Eve", "//Ferdie"], endpoint: "ws://127.0.0.1:9944", types: {} }}
You can also configure test networks, such as mainnet, some_network_name, etc.
{ mainnet: { //... }, some_network_name: { //... }}
The following describes the configuration options of the network part.
Configuration options | Description |
---|---|
[network].gasLimit | Used to set the default value of gaslimit that needs to be provided when instantiating or calling a contract through a transaction. This value must be an integer and has no precision. If this value is too small, contracts.OutOfGas error will be returned. The maximum gaslimit is the maximum value that this Substrate chain uses for DispatchClass::Normal in Runtime. For example, in the configuration of the Node node of Substrate, it is NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT = 75% * 2000000000000 . It is recommended to set this value higher. |
[network].accounts | It is a list composed of suri or KeyringPair. The accounts default is ["//Alice", "//Bob", "//Charlie", "//Dave", "//Eve", "//Ferdie"], please refer to Runtime-environment for details. |
[network].endpoint | Specifies the node that the developer wants to connect to in the current network configuration. Currently, only WebSockets type RPC connections are supported, that is, only link protocols starting with wss:// or ws:// are supported. |
[network].types | Type is a concept defined in Polkadot.js, see types.extend for details. You can also set [`network].typesbundle, [network].typesSpec, etc. If you encounter an error similar to No such variant in enum MultiSignature, you can add {Address: "AccountId", LookupSource: "AccountId"}`to the type, see impact-on-extrinsics for details. |
#
contractIn the contract, you can set the options of the compiler. Currently ink and solang are supported. You can also compile the ink contract and the solang contract under the same project. For details, please refer to the multi-contract compilation example.
Editor Options | Description |
---|---|
[contract].ink.toolchain | Set the toolchain used when cargo-contract compiles the contract. It’s usually nightly . You can also specify nightly-YYYY-MM-DD . |
[contract].ink.sources | Set the directory of the ink contract to be searched during compilation. glob syntax. |
[contract].solang.sources | Set the directory of the solang contract searched during compilation. glob syntax. |
[contract].rpc | Similar to types, RPC is used to specify custom RPC for polkadot.js. For details, please refer to rpc.custom. |
#
pathsPaths can set the directory name of artifacts and tests files. Normally, you don't need to change this.
#
mochaRedspot uses mocha as the testing framework, and all options here will be passed to mocha. For more details, see mocha.