aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui/library.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethereal/ui/library.go')
-rw-r--r--ethereal/ui/library.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/ethereal/ui/library.go b/ethereal/ui/library.go
index 537cfa994..5ca2b4273 100644
--- a/ethereal/ui/library.go
+++ b/ethereal/ui/library.go
@@ -10,6 +10,20 @@ import (
"strings"
)
+type Contract struct {
+ object *ethchain.StateObject
+}
+
+func NewContract(object *ethchain.StateObject) *Contract {
+ return &Contract{object: object}
+}
+
+func (c *Contract) GetStorage(address string) string {
+ val := c.object.GetMem(ethutil.Big("0x" + address))
+
+ return val.BigInt().String()
+}
+
type EthLib struct {
stateManager *ethchain.StateManager
blockChain *ethchain.BlockChain
@@ -43,6 +57,16 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
return mnemonicString, fmt.Sprintf("%x", pair.Address()), fmt.Sprintf("%x", prv), fmt.Sprintf("%x", pub)
}
+func (lib *EthLib) GetKey() string {
+ return ethutil.Hex(ethutil.Config.Db.GetKeys()[0].Address())
+}
+
+func (lib *EthLib) GetStateObject(address string) *Contract {
+ stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address))
+
+ return NewContract(stateObject)
+}
+
func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
var hash []byte
var contractCreation bool