In this line,

    // Set sender address or use a default if none specified
    var addr common.Address
    if args.From == nil {
        if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
            if accounts := wallets[0].Accounts(); len(accounts) > 0 {
                addr = accounts[0].Address
    } else {
        addr = *args.From

if the from is nil, geth uses the first account of the first wallet.

  • What if I don't have any wallet/account in account manager?
  • Will it surprise the user?
  • Why is the from parameter optional?

This is only the Call API expose to everyone then from is not deal. The state is only temporarily for execute the call and cannot update any real state so it do no harm at all.

You can see on the comment code also


// Call executes the given transaction on the state for the given block number.
// It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Bytes, error) {
    result, _, _, err := DoCall(ctx, s.b, args, blockNr, vm.Config{}, 5*time.Second, s.b.RPCGasCap())
    return (hexutil.Bytes)(result), err

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.