Example #1
0
// StorageAt returns the data stores in the state for the given address and location.
func (be *registryAPIBackend) StorageAt(addr string, storageAddr string) string {
	block := be.bc.CurrentBlock()
	state, err := state.New(block.Root(), be.chainDb)
	if err != nil {
		return ""
	}
	return state.GetState(common.HexToAddress(addr), common.HexToHash(storageAddr)).Hex()
}
Example #2
0
// GetStorageAt returns the storage from the state at the given address, key and block number.
func (s *PublicBlockChainAPI) GetStorageAt(address common.Address, key string, blockNr rpc.BlockNumber) (string, error) {
	if block := blockByNumber(s.miner, s.bc, blockNr); block != nil {
		state, err := state.New(block.Root(), s.chainDb)
		if err != nil {
			return "", err
		}

		return state.GetState(address, common.HexToHash(key)).Hex(), nil
	}

	return "0x", nil
}