aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-29 20:10:34 +0800
committerobscuren <geffobscura@gmail.com>2015-01-29 20:10:34 +0800
commit84adf77bf3492351de82f0ec820a1d280e85a5cd (patch)
treee841925b72cbef95cde5d6c8763d145812486336 /xeth
parentf75dcc7f4c60800055f6d15c5e6660ed76465eb6 (diff)
downloadgo-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.gz
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.bz2
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.lz
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.xz
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.zst
go-tangerine-84adf77bf3492351de82f0ec820a1d280e85a5cd.zip
Added RPC "Call" for JS calls to contracts
Diffstat (limited to 'xeth')
-rw-r--r--xeth/xeth.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 89b2459b0..382a1f285 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -204,6 +204,34 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
return toHex(tx.Hash()), nil
}
+func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
+ if len(gasStr) == 0 {
+ gasStr = "100000"
+ }
+ if len(gasPriceStr) == 0 {
+ gasPriceStr = "1"
+ }
+
+ var (
+ statedb = self.chainManager.TransState()
+ initiator = state.NewStateObject(self.eth.KeyManager().KeyPair().Address(), self.eth.Db())
+ block = self.chainManager.CurrentBlock()
+ to = statedb.GetOrNewStateObject(fromHex(toStr))
+ data = fromHex(dataStr)
+ gas = ethutil.Big(gasStr)
+ price = ethutil.Big(gasPriceStr)
+ value = ethutil.Big(valueStr)
+ )
+
+ vmenv := NewEnv(self.chainManager, statedb, block, value, initiator.Address())
+ res, err := vmenv.Call(initiator, to.Address(), data, gas, price, value)
+ if err != nil {
+ return "", err
+ }
+
+ return toHex(res), nil
+}
+
func (self *XEth) Transact(toStr, valueStr, gasStr, gasPriceStr, codeStr string) (string, error) {
var (