This commit is contained in:
SaraJane
2025-12-30 13:07:28 +00:00
commit 93e3f09667
95 changed files with 20233 additions and 0 deletions

View File

@ -0,0 +1,15 @@
_tasks:
- "echo '==== Successfully initialized new smart contract 🚀 ===='"
contract_name:
type: str
help: Name of your new contract.
placeholder: "my-new-contract"
default: "my-new-contract"
include_tests:
type: bool
help: Should we include testing files?
default: 'yes'
_templates_suffix: ".j2"

View File

@ -0,0 +1,7 @@
import { Contract } from '@algorandfoundation/algorand-typescript'
export class {{ contract_name.split('_')|map('capitalize')|join }} extends Contract {
{% if preset_name != 'starter' %}public {% endif %}hello(name: string): string {
return `Hello, ${name}`
}
}

View File

@ -0,0 +1,33 @@
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
import { {{ contract_name.split('_')|map('capitalize')|join }}Factory } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client'
// Below is a showcase of various deployment options you can use in TypeScript Client
export async function deploy() {
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')
const algorand = AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
const factory = algorand.client.getTypedAppFactory({{ contract_name.split('_')|map('capitalize')|join }}Factory, {
defaultSender: deployer.addr,
})
const { appClient, result } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
// If app was just created fund the app account
if (['create', 'replace'].includes(result.operationPerformed)) {
await algorand.send.payment({
amount: (1).algo(),
sender: deployer.addr,
receiver: appClient.appAddress,
})
}
const method = 'hello'
const response = await appClient.send.hello({
args: { name: 'world' },
})
console.log(
`Called ${method} on ${appClient.appClient.appName} (${appClient.appClient.appId}) with name = world, received: ${response.return}`,
)
}

View File

@ -0,0 +1,36 @@
import { Config } from '@algorandfoundation/algokit-utils'
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { Address } from 'algosdk'
import { beforeAll, beforeEach, describe, expect, test } from 'vitest'
import { {{ contract_name.split('_')|map('capitalize')|join }}Factory } from '../artifacts/{{ contract_name }}/{{ contract_name.split('_')|map('capitalize')|join }}Client'
describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () => {
const localnet = algorandFixture()
beforeAll(() => {
Config.configure({
debug: true,
// traceAll: true,
})
})
beforeEach(localnet.newScope)
const deploy = async (account: Address) => {
const factory = localnet.algorand.client.getTypedAppFactory({{ contract_name.split('_')|map('capitalize')|join }}Factory, {
defaultSender: account,
})
const { appClient } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
return { client: appClient }
}
test('says hello', async () => {
const { testAccount } = localnet.context
const { client } = await deploy(testAccount)
const result = await client.send.hello({ args: { name: 'World' } })
expect(result.return).toBe('Hello World')
})
})

View File

@ -0,0 +1,14 @@
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { describe, expect, it } from 'vitest'
import { {{ contract_name.split('_')|map('capitalize')|join }} } from './contract.algo'
describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () => {
const ctx = new TestExecutionContext()
it('Logs the returned value when sayHello is called', () => {
const contract = ctx.contract.create({{ contract_name.split('_')|map('capitalize')|join }})
const result = contract.hello('Sally')
expect(result).toBe('Hello Sally')
})
})

View File

@ -0,0 +1,49 @@
_tasks:
- "echo '==== Successfully generated new .env file 🚀 ===='"
target_network:
type: str
help: Name of your target network.
choices:
- mainnet
- testnet
- localnet
- custom
default: "localnet"
when: "{{ not use_generic_env }}"
custom_network_name:
type: str
help: Name of your custom Algorand network.
placeholder: "custom"
when: "{{ not use_generic_env and target_network == 'custom' }}"
is_localnet:
type: bool
help: Whether to deploy on localnet.
placeholder: "true"
default: "{{ target_network == 'localnet' and not use_generic_env }}"
when: 'false'
is_testnet:
type: bool
help: Whether to deploy on testnet.
placeholder: "true"
default: "{{ target_network == 'testnet' and not use_generic_env }}"
when: 'false'
is_mainnet:
type: bool
help: Whether to deploy on mainnet.
placeholder: "true"
default: "{{ target_network == 'mainnet' and not use_generic_env }}"
when: 'false'
is_customnet:
type: bool
help: Whether to deploy on custom network.
placeholder: "true"
default: "{{ target_network == 'custom' and not use_generic_env }}"
when: 'false'
_templates_suffix: ".j2"

View File

@ -0,0 +1,7 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_TOKEN={YOUR_ALGOD_TOKEN}
ALGOD_SERVER={YOUR_ALGOD_SERVER_URL}
ALGOD_PORT={YOUR_ALGOD_PORT}
INDEXER_TOKEN={YOUR_INDEXER_TOKEN}
INDEXER_SERVER={YOUR_INDEXER_SERVER_URL}
INDEXER_PORT={YOUR_INDEXER_PORT}

View File

@ -0,0 +1,7 @@
# this file should contain environment variables specific to algokit localnet
ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ALGOD_SERVER=http://localhost
ALGOD_PORT=4001
INDEXER_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
INDEXER_SERVER=http://localhost
INDEXER_PORT=8980

View File

@ -0,0 +1,3 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_SERVER=https://mainnet-api.algonode.cloud
INDEXER_SERVER=https://mainnet-idx.algonode.cloud

View File

@ -0,0 +1,3 @@
# this file contains algorand network settings for interacting with testnet via algonode
ALGOD_SERVER=https://testnet-api.algonode.cloud
INDEXER_SERVER=https://testnet-idx.algonode.cloud