0

I'm working with the polkadot-sdk-solochain-template and have successfully executed contract calls using JavaScript (via polkadot‑js). However, I'm facing challenges when trying to call smart contract functions using Rust or Golang.

Here's what I'm trying to do:

Contract Address: 5GwFapTKi6iQaqmbGmXtqkruWBCQChY4xDYTLitnrD78FjJp
Contract Name: user
Function: isUserAdded(did: String) -> Result<Result<bool, UserAuthUserError>, InkPrimitivesLangError>
Input Parameter: "test"
Caller Account: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty
  • My main questions are:

    Which libraries or frameworks in Rust (or Golang) are recommended for interacting with smart contracts in a Substrate/Polkadot environment?

    I've heard that subxt might be a Rust equivalent to polkadot‑js.

    How should I handle ABI encoding/decoding in Rust (or Golang) similar to what polkadot‑js does automatically?

    I need guidance on encoding the function selector and parameters.

    What are the best practices for constructing and submitting extrinsics that interact with smart contracts using the JSON‑RPC interface?

    I'm aware there isn’t a direct contract_call RPC method available on the node.

Has anyone successfully implemented smart contract calls in Rust or Golang with these requirements? Any examples, code snippets (or even pseudo-code), or references to projects would be greatly appreciated.

Thanks in advance for your help!

1 Answer 1

0

subxt is almost the Rust version polkadot-js.

Check the examples directory for more detail.

https://github.com/paritytech/subxt/tree/master/subxt/examples


For ABI encoding, you can use ethabi.

For example, https://github.com/darwinia-network/darwinia/blob/24b523fc6f96dd9670e184633258160750e0437a/pallet/ethtx-forwarder/src/lib.rs#L419.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.