func (svm *SVM) GetBalance(addr types.Address) uint64 {
	return svm.state.GetBalance(addr)
}
GetBalance Retrieve the balance from the given address or 0 if object not found.
package svm
import (
	"fmt"
	"github.com/spacemeshos/go-spacemesh/api/config"
	"github.com/spacemeshos/go-spacemesh/common/types"
	"github.com/spacemeshos/go-spacemesh/common/util"
	"github.com/spacemeshos/go-spacemesh/log"
	"github.com/spacemeshos/go-spacemesh/svm/state"
)
type SVM struct {
	state *state.TransactionProcessor
	log   log.Logger
}
func New(state *state.TransactionProcessor, logger log.Log) *SVM {
	return &SVM{state, log.NewDefault("svm")}
}
func (svm *SVM) SetupGenesis(conf *config.GenesisConfig) error {
	if conf == nil {
		conf = config.DefaultGenesisConfig()
	}
	for id, balance := range conf.Accounts {
		bytes := util.FromHex(id)
		if len(bytes) == 0 {
			return fmt.Errorf("cannot decode entry %s for genesis account", id)
		}
		if len(bytes) != types.AddressLength {
			return fmt.Errorf("%s must be an address of size %d", id, types.AddressLength)
		}
		addr := types.BytesToAddress(bytes)
		svm.state.CreateAccount(addr)
		svm.state.AddBalance(addr, balance)
		svm.log.With().Info("genesis account created",
			log.String("address", addr.Hex()),
			log.Uint64("balance", balance))
	}
	_, err := svm.state.Commit()
	if err != nil {
		return fmt.Errorf("cannot commit genesis state: %w", err)
	}
	return nil
}
func (svm *SVM) ApplyLayer(layerID types.LayerID, transactions []*types.Transaction, rewards map[types.Address]uint64) ([]*types.Transaction, error) {
	svm.state.ApplyRewards(layerID, rewards)
	failedTxs, err := svm.state.ApplyTransactions(layerID, transactions)
	if err != nil {
		return failedTxs, fmt.Errorf("SVM couldn't apply layer %d: %w", layerID.Uint32(), err)
	}
	return failedTxs, nil
}
func (svm *SVM) AddressExists(addr types.Address) bool {
	return svm.state.AddressExists(addr)
}
func (svm *SVM) GetLayerApplied(txID types.TransactionID) *types.LayerID {
	return svm.state.GetLayerApplied(txID)
}
func (svm *SVM) GetLayerStateRoot(layer types.LayerID) (types.Hash32, error) {
	hash, err := svm.state.GetLayerStateRoot(layer)
	if err != nil {
		err = fmt.Errorf("SVM couldn't get the root hash of layer %d: %w", layer.Uint32(), err)
	}
	return hash, err
}
func (svm *SVM) GetStateRoot() types.Hash32 {
	return svm.state.GetStateRoot()
}
func (svm *SVM) LoadState(layer types.LayerID) error {
	if err := svm.state.LoadState(layer); err != nil {
		return fmt.Errorf("SVM couldn't recover the state at layer %d: %w", layer.Uint32(), err)
	}
	return nil
}