Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions skills/controller-backend/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ async function main() {
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678",
amount: "0xffffffffffffffffffffffffffffffff",
description: "Approve spending of tokens",
},
{ name: "transfer", entrypoint: "transfer" },
Expand Down
2 changes: 2 additions & 0 deletions skills/controller-react/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const policies: SessionPolicies = {
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678",
amount: "0xffffffffffffffffffffffffffffffff",
description: "Approve spending of tokens",
},
{ name: "transfer", entrypoint: "transfer" },
Expand Down
1 change: 1 addition & 0 deletions skills/controller-sessions/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const policies: SessionPolicies = {
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678",
amount: "0x3", // Limit: 3 ETH (hex, accounts for decimals)
},
],
Expand Down
2 changes: 2 additions & 0 deletions src/pages/controller/examples/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const policies: SessionPolicies = {
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678",
amount: "0xffffffffffffffffffffffffffffffff",
description: "Approve spending of tokens",
},
{ name: "transfer", entrypoint: "transfer" },
Expand Down
2 changes: 2 additions & 0 deletions src/pages/controller/examples/svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ let controller = new Controller({
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678",
amount: "0xffffffffffffffffffffffffffffffff",
description: "Approve spending of tokens",
},
{
Expand Down
7 changes: 6 additions & 1 deletion src/pages/controller/native/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ const CARTRIDGE_API_URL = 'https://api.cartridge.gg';
const sessionPolicies = {
policies: [
{ contractAddress: '0x049d...', entrypoint: 'transfer' },
{ contractAddress: '0x049d...', entrypoint: 'approve' },
{
contractAddress: '0x049d...',
entrypoint: 'approve',
spender: '0x1234567890abcdef1234567890abcdef12345678',
amount: '0xffffffffffffffffffffffffffffffff'
},
],
maxFee: '0x2386f26fc10000', // ~0.01 ETH
};
Expand Down
10 changes: 9 additions & 1 deletion src/pages/controller/sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ type ContractMethod = {
name: string; // Method name
entrypoint: string; // Contract method entrypoint
description?: string; // Optional method description
amount?: string; // Optional spending limit for approve methods (hex format)
spender?: string; // Required for approve methods: address authorized to spend
amount?: string; // Required for approve methods: spending limit (hex format)
};

type SignMessagePolicy = TypedDataPolicy & {
Expand Down Expand Up @@ -399,6 +400,7 @@ const policies: SessionPolicies = {
{
name: "approve",
entrypoint: "approve",
spender: "0x1234567890abcdef1234567890abcdef12345678", // Address authorized to spend
amount: "0x3", // Limit to 3 ETH (in wei, hex format)
description: "Approve spending up to 3 ETH"
},
Expand All @@ -415,6 +417,7 @@ const policies: SessionPolicies = {
{
name: "approve",
entrypoint: "approve",
spender: "0xabcdef1234567890abcdef1234567890abcdef12", // Address authorized to spend
amount: "0xffffffffffffffffffffffffffffffff", // Unlimited (max uint128)
description: "Approve unlimited STRK spending"
}
Expand All @@ -432,6 +435,11 @@ When users connect with spending limits configured:
- Users see a consent notice explaining the spending permissions
- Unlimited spending limits are clearly labeled as "Unlimited"

**Required Fields for Approve Methods**
- **`spender`**: The contract address authorized to spend tokens (required)
- **`amount`**: The spending limit in hexadecimal format (required)
- Both fields are required to create proper ApprovalPolicy objects and avoid deprecation warnings

**Amount Format**
- Use hexadecimal format (e.g., `"0x3"` for 3, `"0xffffffffffffffffffffffffffffffff"` for unlimited)
- For ERC20 tokens, amounts should account for token decimals
Expand Down