Calling Contract Function via Relayer

:computer: Environment
I'm making a WEBGL Game Using Unity3D

Hello everyone!
I am very new to openzeppelin so please bear with me if i you find my question silly.

I have created a Relayer on BSC testnet. Now i want to call a specfic function of my smart contract with "Send Transaction" of relayer. I have deployed my smart Contract on BSC test and also i have ABI code.

The function of my contract which i want to call, require two arguments (See that function below). How to pass all information and call function with Simple JavaScript HTTP(if possible). Or suggest me a best way to do it.

function declareWinner(string memory roomId, address winner)
        Room storage room = rooms[roomId];


Is Anyone here to help?

Hi @thehk12 -

I think the easiest way would be to use ethers.js. You'll want to use DefenderRelayProvider and DefenderRelaySigner as in the example here:

Instead of ERC20_ADDRESS, use the address of that contract and instead of ERC20_ABI use your ABI and then instead of calling erc20.transfer, you'd want to call something like someContract.declareWinner(roomId, winner) (assuming someContract is the variable that your contract is assigned to - this is erc20 in the example). And you'd need to pass the desired arguments in for roomId and winner.

Please let us know if you have any other questions!

Hello ...

Following up on this. Do you have a solution for Python? Your code example for the txs endpoint does not show any way to specify the function name or its parameters. For example, using, I would want to do something like:

contract = w3.eth.contract( address=0xXXXXX, abi=myabi.json.file)
contract.functions.methodname(param1, param2).build_transaction(...)

Please advise.

Thank you.

FYI ... I ended up writing a Node server that uses ethers to do this (very small number of lines of code!). And then I call that from my Python server. Works great in the absence of a Python DefenderRelayer provider.