以太坊是基于账户的,所以账户余额是在链上。
在block header结构中,有一项Root,是MPT树的root。MPT树下是所有account的信息。Account结构定义如下:
// 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
}
整个数据存储结构参见下图:
http://www.qukuaiwang.com.cn/Public/attached/2017/11/25/151160948589269.jpg