[SOLVED] How to retrieve the result from calling a smart contract function

Hi there! I am new into this and Ive just started a small project playing around with solidity and nextjs. To interact with my contract I am using useWeb3Contract hook but the thing is I am not able to get the response back when calling a create function which is supposed to create and persist a resource and return an identifier back.

To clarify, I am getting a response but the returned hash its not there. Full response example here:

  "hash": "0x3459f2474581d075dacf74d19870502717b1f2c33ffac1fd581ba18deb406a11",
  "type": 2,
  "accessList": null,
  "blockHash": null,
  "blockNumber": null,
  "transactionIndex": null,
  "confirmations": 0,
  "from": "0x41de721E53Db7A0d1a4dB7c1E7B96317C4e7BAD0",
  "gasPrice": {
    "type": "BigNumber",
    "hex": "0x0963e39f96"
  "maxPriorityFeePerGas": {
    "type": "BigNumber",
    "hex": "0x59682f00"
  "maxFeePerGas": {
    "type": "BigNumber",
    "hex": "0x0963e39f96"
  "gasLimit": {
    "type": "BigNumber",
    "hex": "0x010681"
  "to": "0xBeb8C72d500Bdc7183631824CB733b1F51bBdB0B",
  "value": {
    "type": "BigNumber",
    "hex": "0x00"
  "nonce": 32,
  "data": "0x32bac408000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000745737061c3b1610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074672616e63696100000000000000000000000000000000000000000000000000",
  "r": "0x46e5dd31d02f4cfe883438f736f9a8fb1303fcdf5d807a597410b8a281864481",
  "s": "0x7d00b70996018ae50640b2e9f2409b07ec21346c57ddc6f2833a448a5315f7b1",
  "v": 1,
  "creates": null,
  "chainId": 0

And here the result in remix and what i’d like to achieve from my frontend (I mean the decoded output named returnedHash)

status	true Transaction mined and execution succeed
transaction hash	0x687ff294dab3d52f9238b8e2cb95c929df3f5b92dc056f74162a118aa3f11fe7
from	0x5B38Da6a701c568545dCfcB03FcB875f56beddC4
to	Porrachain.createMatch(string,string,uint256) 0xd9145CCE52D386f254917e481eB44e9943F39138
gas	160059 gas
transaction cost	139181 gas 
execution cost	139181 gas 
input	0x32b...00000
decoded input	{
	"string param1": "A",
	"string param2": "B",
	"uint256 param3": "C"
**decoded output	{**
**	"0": "bytes32: returnedHash 0x4132fd365d0584860a6710b3ad1b967b5c6a7b7ff73ebc0e3edd555b6d737fb1"**
logs	[]
val	0 wei

When I tried to call this very function in remix I can see in the debug drpdown the hash (which is a bytes32 hash)

Also I can call public view functions and i can fetch the response so maybe the problem is I am misundestanding how the β€œcreate” functions work in solidity.

Please, some help would be appreciated! See you!

You usually get the data you need from any event(s) that is emitted after that transaction is made on the contract. Or if this transaction changes any state in the contract, you can call the relevant view function to get that state.

1 Like

Oh that makes sense! Than you very much!