Articles
No Results
Article Image

Smart Contract SDK Usage Updated to V2

As part of updating our SDKs to V2, we have been in the process of improving our documentation to reflect the new features. This week we have updated examples that illustrate calling smart contracts with the SDKs. The examples explain the process of using the compiled TEAL within each of the Algorand supported languages (Python, JavaScript, Java, and Go). These examples showcase both contract or escrow style accounts and using TEAL to delegate signature authority.

Before a TEAL program can be used in the SDKs, it must be compiled using the goal tool. The goal TEAL walkthrough documentation explains this process.

Each SDK’s install process is discussed in the SDK Reference documentation. Also, see the Migration guide from V1 to V2

The example code snippets are provided throughout this guide for V2 and are abbreviated for conciseness and clarity. Full running code examples for each SDK are available within the GitHub repo for V1 and V2 at /examples/smart_contracts and for download (.zip).

Contract Account and Delegated Signature Account SDK usage.

When used as a contract account the TEAL code is compiled, which returns an Algorand address. The contract account address can be sent Algos or Algorand Assets from any account using a standard transaction. When sending from a contract account the logic in the TEAL program determines if the transaction is approved. Contract accounts are great for setting up escrow style accounts where say you want to limit withdrawals or you want to do periodic payments, etc.

You can also use TEAL to do delegated signatures, which essentially means you sign a TEAL program with your private key or multisig keys and you can save this logic signature to give to someone else to submit transactions with your authority. The TEAL program can limit the amount of authority you delegate. For example, you can create a delegated signature that allows a utility company to remove up to x Algos every 50000 blocks from your account.

python

java

JavaScript

go

pyteal

smart contracts

asc1

July 08, 2020