xiaohongshu
xiaohongshu
call-smart-contracts
Deploy and interact with Algorand smart contracts using AlgoKit CLI and generated TypeScript clients. Use when deploying contracts to localnet/testnet/mainnet, calling contract methods, reading global/local/box state, opting in or closing out of applications, or writing interaction scripts. Stron...
Full skill instructions
Deploy and interact with Algorand smart contracts using AlgoKit CLI and the generated TypeScript client.
algokit project run buildalgokit project deploy localnetnpx tsx scripts/my-script.tsalgokit project run build
This compiles your contract and generates:
artifacts/<ContractName>/<ContractName>.arc56.json — ARC-56 app specartifacts/<ContractName>/client.ts — Generated TypeScript client# Start localnet if not running
algokit localnet start
# Deploy (runs deploy-config.ts)
algokit project deploy localnet
The deployment script (smart_contracts/deploy-config.ts) handles:
Note the App ID from the deployment output.
Create scripts in your project to call contract methods. Example structure:
// scripts/call-contract.ts
import { AlgorandClient } from '@algorandfoundation/algokit-utils'
import { CounterClient } from '../smart_contracts/artifacts/Counter/client'
async function main() {
// Connect to localnet
const algorand = AlgorandClient.fromEnvironment()
// Get the default account (localnet dispenser)
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
// Create client for deployed app
const client = algorand.client.getTypedAppClientById(CounterClient, {
appId: BigInt(1234), // Replace with actual App ID
sender: deployer,
})
// Call a method
const result = await client.send.increment({})
console.log('New count:', result.return)
// Read global state
const state = await client.state.global.getAll()
console.log('Global state:', state)
}
main().catch(console.error)
Run with:
npx tsx scripts/call-contract.ts
// No arguments
const result = await client.send.increment({})
// With arguments
const result = await client.send.setValue({ args: { value: 42n } })
// Access return value
console.log('Return:', result.return)
// Get all global state
const state = await client.state.global.getAll()
// Get specific key (if typed in contract)
const count = await client.state.global.count()
// Get local state for an address
const localState = await client.state.local(address).getAll()
// If contract has an opt_in method
await client.send.optIn.optIn({})
// Or use bare opt-in
await client.send.optIn.bare({})
// If contract uses boxes
const boxValue = await client.state.box.myBox()
For batch operations across multiple assets:
// Bulk opt-in to multiple assets
const group = algorand.newGroup()
for (const assetId of assetIds) {
group.addAssetOptIn({ sender: account.addr, assetId })
}
await group.send()
// Bulk opt-out from multiple assets
const closeGroup = algorand.newGroup()
for (const assetId of assetIds) {
closeGroup.addAssetOptOut({ sender: account.addr, assetId, creator: creatorAddr })
}
await closeGroup.send()
algokit project run build to generate fresh artifacts.envalgorand.account.fromEnvironment('DEPLOYER') for localnet| Scenario | Approach |
|---|---|
| Deploy to testnet | algokit project deploy testnet (requires funded account) |
| Custom sender | Create account with algorand.account.fromMnemonic() |
| Multiple contracts | Create separate client instances for each |
| State not found | Ensure app is deployed and App ID is correct |
| Method not found | Rebuild contract and regenerate client |
For non-localnet deployments, set environment variables:
# .env file
ALGORAND_NETWORK=testnet
DEPLOYER_MNEMONIC="your twenty four word mnemonic phrase here"
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience