Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
055bb214
Commit
055bb214
authored
4 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
A bit closer, but still fails in the EVM
parent
eba899d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/registro-verificar
+34
-17
34 additions, 17 deletions
bin/registro-verificar
with
34 additions
and
17 deletions
bin/registro-verificar
+
34
−
17
View file @
055bb214
...
...
@@ -8,15 +8,18 @@ var web3 = new Web3( 'http://localhost:8545/' );
var
myArgs
=
process
.
argv
.
slice
(
2
);
var
myaccount
=
myArgs
[
0
];
var
proof
=
myArgs
[
1
];
var
password
=
myArgs
[
2
]
||
''
;
var
contractaddr
;
var
networkid
;
var
chainid
;
var
rawdata
;
var
estimate
;
if
(
myArgs
.
length
!=
2
)
if
(
myArgs
.
length
<
2
||
myArgs
.
length
>
3
)
{
console
.
error
(
"
Wrong number of arguments:
"
+
process
.
argv
[
1
]
+
"
<account> <proof>
"
);
let
myname
=
process
.
argv
[
1
].
replace
(
/^.*
\/
/
,
''
);;
console
.
error
(
"
Wrong number of arguments.
"
);
console
.
error
(
"
Usage:
"
+
myname
+
"
<account> <proof> [<privatekeypassword>]
"
);
process
.
exit
(
1
);
}
...
...
@@ -98,7 +101,7 @@ function loadaccount( path )
}
let
w
;
try
{
w
=
web3
.
eth
.
accounts
.
wallet
.
decrypt
(
[
keystore
],
''
);
w
=
web3
.
eth
.
accounts
.
wallet
.
decrypt
(
[
keystore
],
password
);
}
catch
(
e
)
{
...
...
@@ -172,15 +175,26 @@ function getnonce( account )
function
prepareCall
()
{
var
abi
=
[
{
"
name
"
:
"
proveControl
"
,
"
type
"
:
"
function
"
,
"
inputs
"
:
[
{
"
name
"
:
"
key
"
,
"
type
"
:
"
string
"
}
],
"
outputs
"
:
[
{
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
constant
"
:
false
,
"
payable
"
:
false
,
"
stateMutability
"
:
"
nonpayable
"
}
];
var
abi
=
[
{
"
name
"
:
"
hash
"
,
"
type
"
:
"
function
"
,
"
inputs
"
:
[
{
"
name
"
:
"
key
"
,
"
type
"
:
"
string
"
}
],
"
outputs
"
:
[
{
"
name
"
:
""
,
"
type
"
:
"
bytes32
"
}
],
"
constant
"
:
true
,
"
payable
"
:
false
,
"
stateMutability
"
:
"
pure
"
},
{
"
name
"
:
"
proveControl
"
,
"
type
"
:
"
function
"
,
"
inputs
"
:
[
{
"
name
"
:
"
key
"
,
"
type
"
:
"
string
"
}
],
"
outputs
"
:
[
{
"
name
"
:
""
,
"
type
"
:
"
bool
"
}
],
"
constant
"
:
false
,
"
payable
"
:
false
,
"
stateMutability
"
:
"
nonpayable
"
}
];
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
@@ -197,6 +211,7 @@ function prepareCall()
var
contractInstance
=
new
web3
.
eth
.
Contract
(
abi
,
contractaddr
);
//Estimá el gas que vas a gastar
let
method
=
contractInstance
.
methods
.
proveControl
(
proof
);
// contractInstance.methods.hash(proof).call().then( console.log );
rawdata
=
method
.
encodeABI
();
gasestimate
(
method
).
then
(
resolve
);
...
...
@@ -232,7 +247,7 @@ function signrawtx()
return
promise
;
}
function
printRecept
s
(
r
)
function
printRece
i
pt
(
r
)
{
console
.
log
(
"
blockNumber:
"
+
r
.
blockNumber
);
console
.
log
(
"
transactionHash:
"
+
r
.
transactionHash
);
...
...
@@ -248,12 +263,14 @@ findaccountfile( myaccount )
// Manda la transaccion a la blockchain
.
then
(
tx
=>
{
console
.
log
(
"
Sending this transaction:
"
+
tx
.
rawTransaction
);
// web3.eth.sendSignedTransaction( tx.rawTransaction )
// //Obtené el recibo.
// .once( 'receipt', printReceipt );
console
.
log
(
"
TX hash:
"
+
tx
.
transactionHash
);
//process.exit( 0 );
web3
.
eth
.
sendSignedTransaction
(
tx
.
rawTransaction
)
//Obtené el recibo.
.
once
(
'
receipt
'
,
printReceipt
)
.
catch
(
(
e
)
=>
{
console
.
error
(
"
It would seem that the transaction has failed:
\n
"
+
e
)}
);
})
.
catch
(
e
=>
{
console
.
error
(
"
Oh no. Something most definitely seems to have gone wrong. What I was told is:
"
);
console
.
error
(
e
);
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment