Skip to content

QuantumFusion-network/qf-polkavm-sdk

Repository files navigation

QF Network PolkaVM SDK

License
GitHub contributors GitHub commit activity GitHub last commit
Twitter URL

This framework enables the development of smart contracts for the QF Network. For the smart contract platform implementation details, please refer to the PolkaVM pallet documentation.

For contributing to this project, please read Contributing section.

Compiling example Smart Contract

The QF Network executes smart contracts in the PolkaVM virtual machine and requires PolkaVM tools for smart contracts compilation.

  1. Install polkatool.

    cargo install --git https://github.com/paritytech/polkavm.git --tag v0.21.0 polkatool
  2. Build smart-contract examples/hello-qf-polkavm.

    ./build_polkavm.sh hello-qf-polkavm

    Or compile manually:

    export CRATE_NAME=hello-qf-polkavm
    mkdir -p output
    
    pushd "examples/${CRATE_NAME}"
    RUSTFLAGS="--remap-path-prefix=$(pwd)= --remap-path-prefix=${HOME}=~" \
        cargo +nightly build \
            -Z build-std=core,alloc \
            --target $(polkatool get-target-json-path) \
            -q --release --bin "${CRATE_NAME}" -p "${CRATE_NAME}"
    popd
    
    polkatool link \
        --run-only-if-newer \
        -s "examples/${CRATE_NAME}/target/riscv64emac-unknown-none-polkavm/release/${CRATE_NAME}" \
        -o "output/${CRATE_NAME}.polkavm"

Deploy and call a smart contract

./build_polkavm.sh increment-counter

See guides.md for explaination on how to deploy smart contract on a QF Network Portal.

To run tests on a local network run:

cd cli
npx ts-node upload_and_execute.ts ws://127.0.0.1:9944 ../output/increment-counter.polkavm

Debugging

Run the node with pallet-revive logs and historical state.

qf-node --dev -lerror,runtime::revive::strace=trace,runtime::revive=debug --state-pruning archive

See also https://github.com/paritytech/polkadot-sdk/blob/598feddb/substrate/frame/revive/README.md#host-function-tracing.

Contributing

We welcome contributions of all kinds! Whether you're reporting or fixing a bug, adding a feature, or improving documentation, your help is greatly appreciated. For a bug or vulnerability report please open a new issue.

For code contributions please follow these steps:

  1. Fork the repository and create a new branch following the format your-github-name/descriptive-branch-name (e.g., qf-polkavm-sdk/fix-123).
  2. Make smaller commits with clear messages to simplify reviewer's work.
  3. Submit a pull request targeting main branch and provide a concise description of your changes.

By contributing, you agree to adhere to our Contributor Covenant Code of Conduct, which fosters a respectful and inclusive environment.

We appreciate your support and look forward to your contributions! 🚀

About

QF Contract SDK

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 5