Smart Contracts (ProvWasm)
Web assembly (Wasm) smart contracts for the Provenance Blockchain.
ProvWasm contains extensions for a third party blockchain module. These extensions, combined with a library, provide developers the ability to create web assembly smart contracts for the Provenance Blockchain using the Rust programming language.
The CosmWasm VM only integrates with the
stakingmodules by default. However, it allows for adding custom encoders and queriers. A package was added in the Provenance Blockchain that contain extensions for the following Provenance Blockchain modules:
These extensions are compiled into the blockchain at build time.
The library can be broken down into the following components.
The core of the rust library contains types that are passed to and received from Provenance Blockchain encoders and queriers. Special care must be taken to ensure the Rust types are compatible with Go types in the queriers and encoders. To support this, a semantic data format version is passed through with each message. This enables backward compatability in the blockchain extensions.
A number of high-level functions and types were added to on top of the core parameters to simplify contract development. This will also provide a compatability layer - minimizing changes required to smart contracts when breaking changes are required in the blockchain extensions and core types.
One of the benefits of ProvWasm is that it allows for robust unit testing of smart contracts before deployment to the Provenance Blockchain. Using the types described above, a mock environment can be created so unit tests can run as if they are executing against a running blockchain. This allows developers to ensure their contracts are correct before having to pay fees to deploy to a network.
To ensure the library code works correctly with the blockchain extensions, smart contracts were developed for each custom module in provenance. These contracts can be deployed to a localnet (or the testnet) for integration testing.
There is no guaranteed migration path for smart contracts deployed to provenance, not even "dump state and restart" to move to future versions.
Smart contract technical reference documentation