Skip to content

Commit 64b4196

Browse files
committed
Added anchor example for transfer hook
1 parent 45e302a commit 64b4196

File tree

20 files changed

+2253
-0
lines changed

20 files changed

+2253
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[toolchain]
2+
3+
[features]
4+
resolution = true
5+
skip-lint = false
6+
7+
[programs.localnet]
8+
transfer_hook = "2KKm5dexWn2uw7tPTYs4KYc1R2P111rCu7YUEhZyoLh2"
9+
10+
[registry]
11+
url = "https://api.apr.dev"
12+
13+
[provider]
14+
cluster = "Localnet"
15+
wallet = "~/.config/solana/id.json"
16+
17+
[scripts]
18+
test = "pnpm run ts-mocha -p ./tsconfig.json -t 1000000 tests/*.ts"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
resolver = "2"
6+
7+
[profile.release]
8+
overflow-checks = true
9+
lto = "fat"
10+
codegen-units = 1
11+
[profile.release.build-override]
12+
opt-level = 3
13+
incremental = false
14+
codegen-units = 1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Transfer Hook Transfer Switch
2+
3+
A Solana program that implements token transfer controls using a hook pattern, allowing wallets to be frozen and unfrozen for tokens.
4+
5+
## Prerequisites
6+
7+
- Rust and Cargo
8+
- Solana CLI tools
9+
- Anchor CLI
10+
- Node.js and Yarn
11+
12+
## Setup
13+
14+
1. Clone the repository
15+
16+
```bash
17+
git clone <repository-url>
18+
cd <project-directory>
19+
```
20+
21+
2. Install dependencies:
22+
23+
```bash
24+
pnpm install
25+
```
26+
27+
3. Build the Anchor project
28+
29+
```bash
30+
anchor build
31+
```
32+
33+
4. Sync the program ID:
34+
35+
```bash
36+
anchor keys sync
37+
```
38+
39+
## Running Tests
40+
41+
```bash
42+
anchor test
43+
```
44+
45+
## Notes
46+
47+
- Ensure your Solana validator is running locally before running tests.
48+
- If you encounter any issues, make sure your Anchor.toml and Cargo.toml files are correctly configured for your project.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Migrations are an early feature. Currently, they're nothing more than this
2+
// single deploy script that's invoked from the CLI, injecting a provider
3+
// configured from the workspace's Anchor.toml.
4+
5+
const anchor = require('@coral-xyz/anchor');
6+
7+
module.exports = async (provider) => {
8+
// Configure client to use the provider.
9+
anchor.setProvider(provider);
10+
11+
// Add your deploy script here.
12+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"license": "ISC",
3+
"scripts": {
4+
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
5+
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
6+
"ts-mocha": "ts-mocha"
7+
},
8+
"dependencies": {
9+
"@coral-xyz/anchor": "^0.30.1",
10+
"@solana/spl-token": "^0.4.9",
11+
"@solana/web3.js": "^1.95.4"
12+
},
13+
"devDependencies": {
14+
"@types/chai": "^4.3.7",
15+
"@types/mocha": "10.0.9",
16+
"@types/node": "^22.7.4",
17+
"@types/bn.js": "^5.1.0",
18+
"anchor-bankrun": "^0.5.0",
19+
"borsh": "^2.0.0",
20+
"chai": "^4.3.7",
21+
"mocha": "10.7.3",
22+
"solana-bankrun": "0.4.0",
23+
"ts-mocha": "^10.0.0",
24+
"typescript": "5.6.3"
25+
}
26+
}

0 commit comments

Comments
 (0)