-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation: Adds examples to be pulled into docs (#506)
* starting example location * first example working * more examples * adding more examples * Adding atomic group examples * adding asset examples * adding codec examples * adding indexer examples * starting to add kmd examples * found interface for key export * adding kmd examples * adding randoms * adding participation examples * add fee override example * fmt * add abi type examples * adding example of tws in atc * start to add app examples * adding app examples * Adding lsig examples * adding dryrun examples * shorter api keys, fix fee override --------- Co-authored-by: egieseke <eric_gieseke@yahoo.com> Co-authored-by: John Lee <john.lee@algorand.com> Co-authored-by: Barbara Poon <barbara.poon@algorand.com> Co-authored-by: Lucky Baar <lucky.baar@algorand.com> Co-authored-by: Arthur Kepler <610274+excalq@users.noreply.github.com>
- Loading branch information
1 parent
3b32c33
commit b57b34c
Showing
24 changed files
with
2,101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Algorand Java SDK Examples | ||
|
||
|
||
|
||
Running | ||
-------- | ||
Package with `mvn` | ||
```sh | ||
mvn package | ||
``` | ||
|
||
Run an example with java | ||
```sh | ||
java -cp target/sdk-extras-1.0-SNAPSHOT.jar com.algorand.examples.Example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#pragma version 4 | ||
// Handle each possible OnCompletion type. We don't have to worry about | ||
// handling ClearState, because the ClearStateProgram will execute in that | ||
// case, not the ApprovalProgram. | ||
txn ApplicationID | ||
int 0 | ||
== | ||
bnz handle_approve | ||
|
||
txn OnCompletion | ||
int NoOp | ||
== | ||
bnz handle_noop | ||
|
||
txn OnCompletion | ||
int OptIn | ||
== | ||
bnz handle_approve | ||
|
||
txn OnCompletion | ||
int CloseOut | ||
== | ||
bnz handle_closeout | ||
|
||
txn OnCompletion | ||
int UpdateApplication | ||
== | ||
bnz handle_updateapp | ||
|
||
txn OnCompletion | ||
int DeleteApplication | ||
== | ||
bnz handle_deleteapp | ||
|
||
// Unexpected OnCompletion value. Should be unreachable. | ||
err | ||
|
||
handle_noop: | ||
// Handle NoOp | ||
|
||
// read global state | ||
byte "counter" | ||
dup | ||
app_global_get | ||
|
||
// increment the value | ||
int 1 | ||
+ | ||
|
||
// store to scratch space | ||
dup | ||
store 0 | ||
|
||
// update global state | ||
app_global_put | ||
|
||
// read local state for sender | ||
int 0 | ||
byte "counter" | ||
app_local_get | ||
|
||
// increment the value | ||
int 1 | ||
+ | ||
store 1 | ||
|
||
// update local state for sender | ||
int 0 | ||
byte "counter" | ||
load 1 | ||
app_local_put | ||
|
||
// load return value as approval | ||
load 0 | ||
return | ||
|
||
|
||
handle_closeout: | ||
// Handle CloseOut | ||
//approval | ||
int 1 | ||
return | ||
|
||
handle_deleteapp: | ||
// Check for creator | ||
global CreatorAddress | ||
txn Sender | ||
== | ||
return | ||
|
||
handle_updateapp: | ||
// Check for creator | ||
global CreatorAddress | ||
txn Sender | ||
== | ||
return | ||
|
||
handle_approve: | ||
int 1 | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#pragma version 4 | ||
// Handle each possible OnCompletion type. We don't have to worry about | ||
// handling ClearState, because the ClearStateProgram will execute in that | ||
// case, not the ApprovalProgram. | ||
|
||
txn ApplicationID | ||
int 0 | ||
== | ||
bnz handle_approve | ||
|
||
txn OnCompletion | ||
int NoOp | ||
== | ||
bnz handle_noop | ||
|
||
txn OnCompletion | ||
int OptIn | ||
== | ||
bnz handle_approve | ||
|
||
txn OnCompletion | ||
int CloseOut | ||
== | ||
bnz handle_closeout | ||
|
||
txn OnCompletion | ||
int UpdateApplication | ||
== | ||
bnz handle_updateapp | ||
|
||
txn OnCompletion | ||
int DeleteApplication | ||
== | ||
bnz handle_deleteapp | ||
|
||
// Unexpected OnCompletion value. Should be unreachable. | ||
err | ||
|
||
handle_noop: | ||
// Handle NoOp | ||
|
||
// read global state | ||
byte "counter" | ||
dup | ||
app_global_get | ||
|
||
// increment the value | ||
int 1 | ||
+ | ||
|
||
// store to scratch space | ||
dup | ||
store 0 | ||
|
||
// update global state | ||
app_global_put | ||
|
||
// read local state for sender | ||
int 0 | ||
byte "counter" | ||
app_local_get | ||
|
||
// increment the value | ||
int 1 | ||
+ | ||
store 1 | ||
|
||
// update local state for sender | ||
// update "counter" | ||
int 0 | ||
byte "counter" | ||
load 1 | ||
app_local_put | ||
|
||
// update "timestamp" | ||
int 0 | ||
byte "timestamp" | ||
txn ApplicationArgs 0 | ||
app_local_put | ||
|
||
// load return value as approval | ||
load 0 | ||
return | ||
|
||
handle_closeout: | ||
// Handle CloseOut | ||
//approval | ||
int 1 | ||
return | ||
|
||
handle_deleteapp: | ||
// Check for creator | ||
global CreatorAddress | ||
txn Sender | ||
== | ||
return | ||
|
||
handle_updateapp: | ||
// Check for creator | ||
global CreatorAddress | ||
txn Sender | ||
== | ||
return | ||
|
||
handle_approve: | ||
int 1 | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma version 4 | ||
int 1 | ||
return |
Oops, something went wrong.