1

I have a smart contract written in solidity. I deployed the contract to my Ganache network and I can interact with it via go-ethereum using stubs generated by abigen. My function returns a uint256, what I want to do is see this contract return data via the stubs I have generated with abigen.

I can successfully interact with the contract. I just want to know how to use the returned types.Transaction to obtain what my contract function returns - I am guessing the decode 'instructions' are in the generated abi. thanks

    instance, _ := tictac.NewTictac(address, client)

    privateKey, _ := crypto.HexToECDSA("1234")

    transactOpts := bind.NewKeyedTransactor(privateKey)
    publicKey := privateKey.Public()
    publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)

    fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)

    gasPrice, _ := client.SuggestGasPrice(context.Background())

opts := &bind.TransactOpts{
    From:     fromAddress,
    Signer:   transactOpts.Signer,
    Value:    big.NewInt(1),
    GasPrice: gasPrice,
    GasLimit: 1000000,
}

    types, _ := instance.StartGame(opts, "player1", true, big.NewInt(1))

1 Answer 1

1

Not possible yet. You can use Events

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.