Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-sdk-go
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
chain33-sdk-go
Commits
50c8a8ae
Commit
50c8a8ae
authored
Mar 26, 2021
by
袁兴强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
9039974b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
wasm.go
dapp/wasm/wasm.go
+11
-4
No files found.
dapp/wasm/wasm.go
View file @
50c8a8ae
package
wasm
package
wasm
import
(
import
(
sdk
"github.com/33cn/chain33-sdk-go"
"github.com/33cn/chain33-sdk-go/crypto"
"io/ioutil"
"io/ioutil"
"math/rand"
"math/rand"
"time"
sdk
"github.com/33cn/chain33-sdk-go"
"github.com/33cn/chain33-sdk-go/crypto"
"github.com/33cn/chain33-sdk-go/types"
"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
)
{
func
CreateWasmCreateTx
(
paraName
,
path
,
name
string
,
privKey
,
cert
,
uid
[]
byte
)
(
*
types
.
Transaction
,
error
)
{
code
,
err
:=
ioutil
.
ReadFile
(
path
)
code
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -23,7 +30,7 @@ func CreateWasmCreateTx(paraName, path, name string, privKey, cert, uid []byte)
...
@@ -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
:
r
and
.
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
)
tx
,
err
=
sdk
.
Sign
(
tx
,
privKey
,
crypto
.
SM2
,
uid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -44,7 +51,7 @@ func CreateWasmCallTx(paraName, contract, method string, param []int64, env []st
...
@@ -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
:
r
and
.
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
var
err
error
tx
,
err
=
sdk
.
Sign
(
tx
,
privKey
,
crypto
.
SM2
,
uid
)
tx
,
err
=
sdk
.
Sign
(
tx
,
privKey
,
crypto
.
SM2
,
uid
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment