Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Adds examples to be pulled into docs #506

Merged
merged 41 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
88d88b0
Merge branch 'release/1.11.0-beta-1'
egieseke Dec 7, 2021
b79ae34
Merge branch 'release/1.11.0-beta-2'
egieseke Dec 30, 2021
15ee9b9
Merge branch 'release/1.11.0'
egieseke Jan 14, 2022
7d2f24a
Merge branch 'release/1.12.0-beta-1'
onetechnical Feb 15, 2022
a44b312
Merge branch 'release/1.12.0'
onetechnical Mar 2, 2022
5458e92
Merge branch 'release/1.13.0-beta-1'
algobarb Mar 17, 2022
da304e9
Merge branch 'release/1.13.0'
egieseke Mar 23, 2022
6506e97
Merge branch 'release/1.14.0'
onetechnical May 2, 2022
704d1fe
Merge branch 'release/1.15.0'
onetechnical Jun 2, 2022
5bc4069
Merge branch 'release/1.16.0'
algolucky Jun 21, 2022
b9fa576
Merge branch 'release/1.17.0'
algobarb Aug 18, 2022
ceaa5fb
Merge branch 'release/1.18.0'
egieseke Sep 6, 2022
66a6cac
Merge branch 'release/1.19.0'
algobarb Sep 22, 2022
ac47dc5
Merge branch 'release/1.19.0'
algobarb Sep 22, 2022
0182a2e
Merge branch 'release/1.20.0'
algobarb Oct 12, 2022
1f4b6a7
Merge branch 'release/1.21.0'
egieseke Nov 7, 2022
4c4969d
Merge branch 'release/1.21.1'
excalq Nov 10, 2022
94032f7
Merge branch 'release/1.22.0'
algobarb Dec 6, 2022
910098e
Merge branch 'release/2.0.0'
algolucky Jan 3, 2023
4335e6c
starting example location
barnjamin Feb 25, 2023
5b1c7b5
first example working
barnjamin Feb 25, 2023
b593f3c
more examples
barnjamin Feb 27, 2023
5e2ae35
adding more examples
barnjamin Feb 28, 2023
832ebdb
Adding atomic group examples
barnjamin Feb 28, 2023
2feb59d
adding asset examples
barnjamin Feb 28, 2023
af3e068
adding codec examples
barnjamin Feb 28, 2023
7f13b7f
adding indexer examples
barnjamin Feb 28, 2023
e699775
starting to add kmd examples
barnjamin Feb 28, 2023
076a859
found interface for key export
barnjamin Feb 28, 2023
5ce36cb
adding kmd examples
barnjamin Mar 1, 2023
249f8f7
adding randoms
barnjamin Mar 1, 2023
eede000
adding participation examples
barnjamin Mar 1, 2023
baf217c
add fee override example
barnjamin Mar 1, 2023
4d0a66c
fmt
barnjamin Mar 1, 2023
1d2b525
add abi type examples
barnjamin Mar 1, 2023
d1843c3
adding example of tws in atc
barnjamin Mar 1, 2023
780477c
start to add app examples
barnjamin Mar 2, 2023
cf8659d
adding app examples
barnjamin Mar 3, 2023
2db1ebe
Adding lsig examples
barnjamin Mar 6, 2023
ef87cb9
adding dryrun examples
barnjamin Mar 6, 2023
0a52915
shorter api keys, fix fee override
barnjamin Mar 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/README.md
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
```
100 changes: 100 additions & 0 deletions examples/application/approval.teal
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
107 changes: 107 additions & 0 deletions examples/application/approval_refactored.teal
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
3 changes: 3 additions & 0 deletions examples/application/clear.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma version 4
int 1
return
Loading