2

Maybe I missed it, but can't seem to find it anywhere. Is the unit used in Gwei or in Eth?

For example when writing :

stateDb, err := state.New(rootHash, db)
if err!=nil{
   return err
}
addressA := common.HexToAddress("0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B")

stateDb.SetBalance(addressA, big.NewInt(1000))

do we get 1000 eth or 1000 wei?

Any help appreciated

2 Answers 2

2

From state_object.go, the state code deals with the following account representation:

// Account is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type Account struct {
    Nonce    uint64
    Balance  *big.Int
    Root     common.Hash // merkle root of the storage trie
    CodeHash []byte
}

setBalance() works on this representation of Balance.

The state representation in the code is a direct implementation of the specification in the Yellow Paper. The description of world state in section 4.1 of the Yellow Paper has this to say:

balance: A scalar value equal to the number of Wei owned by this address

1
  • 1
    No problem, glad it helped :-) Commented Jan 25, 2019 at 18:19
1

It is impossible to answer without more information or code to see.

However, it is likely in wei. All values in Solidity are in wei, unless they are suffixed with a keyword such as ether, szabo, or finney.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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