Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张蕾
Geth-Modification
Commits
011fdd91
Commit
011fdd91
authored
Feb 02, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event_inc example
parent
d5166918
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
event_inc.html
example/event_inc.html
+66
-0
No files found.
example/event_inc.html
0 → 100644
View file @
011fdd91
<
!
doctype
>
<html>
<head>
<script
type=
"text/javascript"
src=
"js/bignumber.js/bignumber.min.js"
></script>
<script
type=
"text/javascript"
src=
"../dist/ethereum.js"
></script>
<script
type=
"text/javascript"
>
var
web3
=
require
(
'web3'
);
web3
.
setProvider
(
new
web3
.
providers
.
HttpSyncProvider
(
'http://localhost:8080'
));
var
source
=
""
+
"contract Contract { "
+
" event Incremented(bool indexed odd, uint x); "
+
" function Contract() { "
+
" x = 69; "
+
" } "
+
" function inc() { "
+
" ++x; "
+
" Incremented(x % 2 == 1, x); "
+
" } "
+
" uint x; "
+
"}"
;
var
desc
=
[{
"type"
:
"event"
,
"name"
:
"Incremented"
,
"inputs"
:
[{
"name"
:
"odd"
,
"type"
:
"bool"
,
"indexed"
:
true
},{
"name"
:
"x"
,
"type"
:
"uint"
,
"indexed"
:
false
}],
},
{
"type"
:
"function"
,
"name"
:
"inc"
,
"inputs"
:
[],
"outputs"
:
[]
}];
var
address
;
var
contract
;
var
update
=
function
(
x
)
{
document
.
getElementById
(
'result'
).
innerText
=
JSON
.
stringify
(
x
);
};
var
createContract
=
function
()
{
address
=
web3
.
eth
.
transact
({
code
:
web3
.
eth
.
solidity
(
source
)});
contract
=
web3
.
eth
.
contract
(
address
,
desc
);
contract
.
Incremented
({
odd
:
true
}).
changed
(
update
);
};
var
callContract
=
function
()
{
contract
.
call
().
inc
();
};
</script>
</head>
<body>
<div>
<button
type=
"button"
onClick=
"createContract();"
>
create contract
</button>
</div>
<div>
<button
type=
"button"
onClick=
"callContract();"
>
test1
</button>
</div>
<div
id=
"result"
>
</div>
</body>
</html>
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