Commit 50c8a8ae authored by 袁兴强's avatar 袁兴强

update

parent 9039974b
package wasm
import (
sdk "github.com/33cn/chain33-sdk-go"
"github.com/33cn/chain33-sdk-go/crypto"
"io/ioutil"
"math/rand"
"time"
sdk "github.com/33cn/chain33-sdk-go"
"github.com/33cn/chain33-sdk-go/crypto"
"github.com/33cn/chain33-sdk-go/types"
)
var r *rand.Rand
func init() {
r = rand.New(rand.NewSource(time.Now().UnixNano()))
}
func CreateWasmCreateTx(paraName, path, name string, privKey, cert, uid []byte) (*types.Transaction, error) {
code, err := ioutil.ReadFile(path)
if err != nil {
......@@ -23,7 +30,7 @@ func CreateWasmCreateTx(paraName, path, name string, privKey, cert, uid []byte)
},
},
}
tx := &types.Transaction{Execer: []byte(paraName + WasmX), Payload: types.Encode(payload), Fee: 1e5, Nonce: rand.Int63()}
tx := &types.Transaction{Execer: []byte(paraName + WasmX), Payload: types.Encode(payload), Fee: 1e5, Nonce: r.Int63(), To: crypto.GetExecAddress(paraName + WasmX)}
tx, err = sdk.Sign(tx, privKey, crypto.SM2, uid)
if err != nil {
return nil, err
......@@ -44,7 +51,7 @@ func CreateWasmCallTx(paraName, contract, method string, param []int64, env []st
},
},
}
tx := &types.Transaction{Execer: []byte(paraName + WasmX), Payload: types.Encode(payload), Fee: 1e5, Nonce: rand.Int63()}
tx := &types.Transaction{Execer: []byte(paraName + WasmX), Payload: types.Encode(payload), Fee: 1e5, Nonce: r.Int63(), To: crypto.GetExecAddress(paraName + WasmX)}
var err error
tx, err = sdk.Sign(tx, privKey, crypto.SM2, uid)
if err != nil {
......@@ -52,4 +59,4 @@ func CreateWasmCallTx(paraName, contract, method string, param []int64, env []st
}
tx.Signature.Signature = crypto.EncodeCertToSignature(tx.Signature.Signature, cert, uid)
return tx, nil
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment