1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using go to make a contract call without private key like web3 does?

Discussion in 'Programming/Internet' started by Corey Ogburn, Oct 8, 2018.

  1. Corey Ogburn

    Corey Ogburn Guest

    I'm working on moving a node project of ours over to a go project and I've run into an issue:

    web3.eth.defaultAccount = web3.eth.accounts[0];


    In node using web3 this is all I had to do for every transaction to go out as that address. No private key, no passphrase. However in go I'm running in to an issue when building TransactOpts for my contract calls:

    opts := bind.TransactOpts{
    Context: context.Background(),
    From: fromAddress,
    GasLimit: big.NewInt(1000000),
    GasPrice: big.NewInt(0),
    }


    Here I specify the From but since I don't specify the Signer property I get an error no signer to authorize the transaction with and sure enough this page marks the Signer field as mandatory.

    How, from go, should I be making my transactional contract calls? Ideally without private keys and passphrases being accessed.

    EDIT: As I looked more into how Web3 does what it does, I realized that it was part of our process to leave that address unlocked. It was part of our script to mine to unlock that address until further notice. If Node still requires the address to be unlocked then I see less of an issue having to unlock it in Go. Unless I find a better way, I'll be using the keystore object to unlock an account and construct a transactor.

    Login To add answer/comment
     

Share This Page