MCPcopy Create free account
hub / github.com/DNAProject/DNA / GetAccountBalance

Function GetAccountBalance

cmd/utils/gas.go:84–100  ·  view source on GitHub ↗
(address, asset string)

Source from the content-addressed store, hash-verified

82}
83
84func GetAccountBalance(address, asset string) (uint64, error) {
85 balances, err := GetBalance(address)
86 if err != nil {
87 return 0, err
88 }
89 var balance uint64
90 switch strings.ToLower(asset) {
91 case "gas":
92 balance, err = strconv.ParseUint(balances.Gas, 10, 64)
93 default:
94 return 0, fmt.Errorf("unsupport asset:%s", asset)
95 }
96 if err != nil {
97 return 0, err
98 }
99 return balance, nil
100}
101
102func GetAllowance(asset, from, to string) (string, error) {
103 result, ontErr := sendRpcRequest("getallowance", []interface{}{asset, from, to})

Callers 2

transferFunction · 0.92
transferFromFunction · 0.92

Calls 2

ErrorfMethod · 0.80
GetBalanceFunction · 0.70

Tested by

no test coverage detected