Skip to content

polkadot-api/revive-deploy-solidity

Repository files navigation

Deploy and call solidity contracts

This is an example repository that shows how to deploy and call solidity contracts on polkadot's pallet revive, using a regular polkadot node.

Getting Started

You will need bun installed in your system. Then run:

bun i
bun codegen

This will install the necessary packages and generate the contract's ABI, code and chain types.

It relies on:

  • @parity/resolc to generate ABI+PVM from .sol.
  • @wagmi/cli to generate the ABI types.
  • viem to encode and decode function calls (fully typed).
  • polkadot-api to connect and interact with revive pallet.

Usage

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.ts to deploy the contract.
    • For the account name you can put any string
    • e.g. bun run deploy Alice will 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
  • bun winning {dev account name} {address}
    • Runs src/winning.ts to read from a view-only function and storage.
    • Gets the current winning proposal.
  • bun vote {dev account name} {address} {vote: 0|1}
    • Runs src/vote.ts to call a contract function.
    • Votes for one of the proposals, indexed by 0 or 1.

License

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.

About

Deploying and intreacting with solidity contracts in pallet revive

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published