This is an example repository that shows how to deploy and call solidity contracts on polkadot's pallet revive, using a regular polkadot node.
You will need bun installed in your system. Then run:
bun i
bun codegenThis will install the necessary packages and generate the contract's ABI, code and chain types.
It relies on:
@parity/resolcto generate ABI+PVM from.sol.@wagmi/clito generate the ABI types.viemto encode and decode function calls (fully typed).polkadot-apito connect and interact with revive pallet.
The contract source is 3_Ballot.sol. This is an example contract found in Remix https://remix.polkadot.io/, which puts some proposals up for voting and different accounts can vote them.
This repo has 3 scripts ready to interact with the contract:
bun run deploy {dev account name}- Runs
src/deploy.tsto deploy the contract. - For the account name you can put any string
- e.g.
bun run deploy Alicewill deploy as Alice, but please use your own name, the script will guide you in case you need to set your account up. - Will give you a deployment address as a result
- Runs
bun winning {dev account name} {address}- Runs
src/winning.tsto read from a view-only function and storage. - Gets the current winning proposal.
- Runs
bun vote {dev account name} {address} {vote: 0|1}- Runs
src/vote.tsto call a contract function. - Votes for one of the proposals, indexed by 0 or 1.
- Runs
Copyright 2025 Polkadot-API
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.