Skip to content

Instantly share code, notes, and snippets.

@algochoi
algochoi / abi_test_contract.py
Last active November 8, 2021 17:04
PyTeal contract for ABI testing
from pyteal import *
# Method selectors
add_method_selector = Bytes("base16", "0xfe6bdf69")
empty_method_selector = Bytes("base16", "0xa88c26a5")
payment_method_selector = Bytes("base16", "0x535a47ba")
# Method signature should be: add(uint64,uint64)uint64
@Subroutine(TealType.none)
def add(a, b):
@algochoi
algochoi / cadenza-image.png
Created April 7, 2022 16:49
cadenza-image
a
@algochoi
algochoi / pyteal_audit_thoughts.md
Last active October 3, 2022 15:06
PyTeal Good practices for Audits

Writing PyTeal Contracts for audits

Some thoughts to keep in mind when developing PyTeal smart contracts. Hopefully, these points will make it easier for reviewers and auditors to read and understand the contract logic.

Using pragma to enforce a PyTeal compiler version

Since PyTeal is still under active development, there may be bugs fixes or patches in future versions. Although specifying the exact compiler version is likely the best practice, allowing minor version bumps through the caret (^) seems acceptable too.

from pyteal import *
# Enforce a minimum PyTeal compiler version of 0.18.1, 
@algochoi
algochoi / disassemble-test.go
Created November 28, 2022 17:55
Disassemble endpoint Go SDK test
package main
import (
"context"
"encoding/base64"
"fmt"
"strings"
"github.com/algorand/go-algorand-sdk/client/v2/algod"
)
@algochoi
algochoi / devmode-notes.md
Last active April 4, 2023 04:06
Dev mode node notes

Developer node

Some notes on dev mode

Configurations

Dev mode is a boolean that can be set in the genesis file. This is read into the Genesis struct in data/bookkeeping/genesis.go. This is also recorded to the full node config AlgorandFullNode.

Node functions

When in dev mode, the node factory MakeFull in node/node.go will initialize a frozen clock for the dev mode node.

@algochoi
algochoi / dev_mode_improvements.teal
Created April 13, 2023 21:09
Dev mode improved opcodes
#pragma version 7
global LatestTimestamp
itob
log
txn FirstValidTime
itob
log