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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
wasm.go
dapp/wasm/wasm.go
+12
-6
No files found.
dapp/wasm/wasm.go
View file @
50c8a8ae
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
:
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
)
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
:
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
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
}
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