├── nfts ├── mint-nft │ ├── solpg │ │ └── idl.json │ ├── Cargo.toml │ ├── programs │ │ └── mint-nft │ │ │ ├── Xargo.toml │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── lib.rs │ ├── .gitignore │ ├── .prettierignore │ ├── tsconfig.json │ ├── Anchor.toml │ ├── assets │ │ └── example.json │ ├── migrations │ │ └── deploy.ts │ ├── package.json │ └── tests │ │ └── mint-nft.ts ├── nft-collection │ ├── app │ │ ├── src │ │ │ ├── util │ │ │ │ ├── const.ts │ │ │ │ ├── types.ts │ │ │ │ └── rpc.ts │ │ │ ├── App.js │ │ │ ├── setupTests.js │ │ │ ├── App.test.js │ │ │ ├── index.js │ │ │ ├── components │ │ │ │ ├── Nft.tsx │ │ │ │ └── Collection.tsx │ │ │ ├── index.css │ │ │ ├── reportWebVitals.js │ │ │ ├── App.css │ │ │ └── logo.svg │ │ ├── public │ │ │ ├── robots.txt │ │ │ ├── favicon.ico │ │ │ ├── logo192.png │ │ │ ├── logo512.png │ │ │ ├── manifest.json │ │ │ └── index.html │ │ ├── tsconfig.json │ │ ├── .gitignore │ │ └── package.json │ └── anchor │ │ ├── Cargo.toml │ │ ├── .gitignore │ │ ├── programs │ │ └── nft-collection │ │ │ ├── Xargo.toml │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── sell.rs │ │ │ └── mint.rs │ │ ├── .prettierignore │ │ ├── tests │ │ ├── keypairs │ │ │ └── buyer1.json │ │ ├── util.ts │ │ ├── test-sell.ts │ │ └── test-mint.ts │ │ ├── tsconfig.json │ │ ├── Anchor.toml │ │ └── package.json ├── sell-nft │ ├── Cargo.toml │ ├── programs │ │ └── mint-nft │ │ │ ├── Xargo.toml │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── sell.rs │ │ │ └── mint.rs │ ├── .gitignore │ ├── .prettierignore │ ├── tests │ │ ├── keypairs │ │ │ └── buyer1.json │ │ ├── util.ts │ │ ├── test-sell.ts │ │ └── test-mint.ts │ ├── tsconfig.json │ ├── Anchor.toml │ ├── migrations │ │ └── deploy.ts │ └── package.json ├── nft-marketplace │ ├── Cargo.toml │ ├── .gitignore │ ├── programs │ │ └── nft-marketplace │ │ │ ├── Xargo.toml │ │ │ ├── src │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ ├── .prettierignore │ ├── tsconfig.json │ ├── Anchor.toml │ ├── migrations │ │ └── deploy.ts │ ├── package.json │ └── tests │ │ └── nft-marketplace.ts ├── nft-marketplace-live │ ├── Cargo.toml │ ├── .gitignore │ ├── .prettierignore │ ├── programs │ │ └── nft-marketplace-live │ │ │ ├── Xargo.toml │ │ │ ├── src │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ ├── tsconfig.json │ ├── Anchor.toml │ ├── migrations │ │ └── deploy.ts │ ├── package.json │ └── tests │ │ └── nft-marketplace-live.ts ├── mint-nft-raw │ ├── .gitignore │ ├── build.sh │ ├── util.ts │ ├── mint │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── package.json │ └── app.ts ├── how_nfts_work.jpg ├── nfts_more_detail.jpg └── README.md ├── pdas ├── README.md ├── Cargo.toml ├── pdas.jpg ├── programs │ └── pdas │ │ ├── Xargo.toml │ │ ├── Cargo.toml │ │ └── src │ │ └── lib.rs ├── .gitignore ├── .prettierignore ├── tsconfig.json ├── Anchor.toml ├── migrations │ └── deploy.ts ├── package.json ├── tests │ └── pdas.ts └── Cargo.lock ├── transfer-sol ├── .gitignore ├── _dist │ └── program │ │ ├── program.so │ │ └── program-keypair.json ├── accounts │ ├── george.json │ ├── john.json │ ├── paul.json │ └── ringo.json ├── program │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── package.json ├── README.md ├── _cicd │ └── cicd.sh └── client │ └── main.ts ├── hello-solana ├── .gitignore ├── dist │ └── program │ │ ├── hello_solana.so │ │ └── hello_solana-keypair.json ├── src │ ├── program │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── client │ │ └── main.ts ├── README.md ├── Dockerfile └── package.json ├── advanced-math ├── .gitignore ├── dist │ └── program │ │ ├── calculator.so │ │ └── calculator-keypair.json ├── README.md ├── src │ ├── calculator │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── calculator.rs │ │ │ └── lib.rs │ └── client │ │ ├── util.ts │ │ ├── calculator.ts │ │ └── math.ts ├── package.json └── scripts │ └── cicd.sh ├── math-stuff ├── .gitignore ├── dist │ └── program │ │ ├── sum.so │ │ ├── square.so │ │ ├── square-keypair.json │ │ └── sum-keypair.json ├── solana-accounts.jpg ├── src │ ├── sum │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ ├── square │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── client │ │ ├── util.ts │ │ ├── sum.ts │ │ ├── square.ts │ │ └── math.ts ├── Dockerfile ├── README.md ├── package.json └── scripts │ └── cicd.sh ├── solana-cli ├── solana_alpine.Dockerfile └── README.md ├── README.md └── LICENSE /nfts/mint-nft/solpg/idl.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/util/const.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/util/types.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pdas/README.md: -------------------------------------------------------------------------------- 1 | # PDAs 2 | 3 | ![](pdas.jpg) -------------------------------------------------------------------------------- /transfer-sol/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | program/target/ -------------------------------------------------------------------------------- /hello-solana/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | src/program/target/ -------------------------------------------------------------------------------- /advanced-math/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | src/calculator/target/ -------------------------------------------------------------------------------- /math-stuff/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | src/sum/target/ 3 | src/square/target/ -------------------------------------------------------------------------------- /pdas/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /nfts/mint-nft/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /nfts/sell-nft/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "programs/*" 4 | ] 5 | -------------------------------------------------------------------------------- /pdas/pdas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/pdas/pdas.jpg -------------------------------------------------------------------------------- /pdas/programs/pdas/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /pdas/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /nfts/mint-nft-raw/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | mint/Cargo.lock 3 | mint/target/ 4 | package-lock.json 5 | dist/ -------------------------------------------------------------------------------- /nfts/mint-nft/programs/mint-nft/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /nfts/sell-nft/programs/mint-nft/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /nfts/how_nfts_work.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/nfts/how_nfts_work.jpg -------------------------------------------------------------------------------- /nfts/mint-nft/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /nfts/sell-nft/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /pdas/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /nfts/mint-nft/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /nfts/sell-nft/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | **/*.rs.bk 6 | node_modules 7 | test-ledger 8 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/programs/nft-marketplace/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /nfts/nfts_more_detail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/nfts/nfts_more_detail.jpg -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/programs/nft-collection/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /math-stuff/dist/program/sum.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/math-stuff/dist/program/sum.so -------------------------------------------------------------------------------- /math-stuff/solana-accounts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/math-stuff/solana-accounts.jpg -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/.prettierignore: -------------------------------------------------------------------------------- 1 | 2 | .anchor 3 | .DS_Store 4 | target 5 | node_modules 6 | dist 7 | build 8 | test-ledger 9 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/programs/nft-marketplace-live/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] 3 | -------------------------------------------------------------------------------- /math-stuff/dist/program/square.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/math-stuff/dist/program/square.so -------------------------------------------------------------------------------- /nfts/nft-collection/app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": false, 4 | "jsx": "preserve" 5 | } 6 | } -------------------------------------------------------------------------------- /transfer-sol/_dist/program/program.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/transfer-sol/_dist/program/program.so -------------------------------------------------------------------------------- /nfts/mint-nft-raw/build.sh: -------------------------------------------------------------------------------- 1 | cargo build-bpf --manifest-path=./mint/Cargo.toml --bpf-out-dir=./dist/program 2 | solana program deploy dist/program/mint.so -------------------------------------------------------------------------------- /advanced-math/dist/program/calculator.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/advanced-math/dist/program/calculator.so -------------------------------------------------------------------------------- /hello-solana/dist/program/hello_solana.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/hello-solana/dist/program/hello_solana.so -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/nfts/nft-collection/app/public/favicon.ico -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/nfts/nft-collection/app/public/logo192.png -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Solana-Tutorial/HEAD/nfts/nft-collection/app/public/logo512.png -------------------------------------------------------------------------------- /advanced-math/README.md: -------------------------------------------------------------------------------- 1 | # Advanced Math 2 | 3 | Demonstrating passing instructions to a Solana (Rust) program. 4 | 5 | ```shell 6 | npm i @solana/buffer-layout buffer 7 | ``` -------------------------------------------------------------------------------- /transfer-sol/accounts/george.json: -------------------------------------------------------------------------------- 1 | [96,67,239,107,21,172,158,69,75,79,38,158,31,9,240,240,45,180,86,79,143,62,107,47,53,33,46,60,45,117,116,234,219,94,220,139,240,169,94,207,133,62,44,184,158,54,67,178,87,242,197,147,153,51,81,188,107,160,52,254,74,221,138,142] -------------------------------------------------------------------------------- /math-stuff/dist/program/square-keypair.json: -------------------------------------------------------------------------------- 1 | [9,92,4,148,140,135,81,144,17,134,33,57,188,27,227,230,202,252,18,115,90,249,99,214,48,57,59,64,14,224,145,60,107,114,180,133,109,43,167,90,7,122,24,210,139,242,96,251,3,146,212,104,230,61,170,9,183,194,204,100,45,135,155,16] -------------------------------------------------------------------------------- /math-stuff/dist/program/sum-keypair.json: -------------------------------------------------------------------------------- 1 | [42,69,169,19,111,193,172,150,145,13,26,168,26,82,175,239,20,216,14,23,216,197,142,68,47,225,14,73,132,103,120,163,69,99,42,13,235,142,40,205,93,4,141,156,76,28,28,150,93,106,69,230,242,242,153,37,99,30,109,238,48,184,197,83] -------------------------------------------------------------------------------- /transfer-sol/accounts/john.json: -------------------------------------------------------------------------------- 1 | [219,96,163,187,54,156,106,130,155,52,18,109,59,59,206,218,142,202,165,197,161,173,229,113,118,148,218,221,248,76,188,102,17,76,245,89,83,127,117,31,214,195,252,179,145,53,73,134,6,6,18,120,122,125,244,172,9,200,7,171,20,255,164,161] -------------------------------------------------------------------------------- /transfer-sol/accounts/paul.json: -------------------------------------------------------------------------------- 1 | [43,108,134,198,172,130,122,247,156,154,229,245,215,110,151,21,21,248,59,188,168,1,155,160,135,196,34,166,77,108,20,111,24,81,183,171,90,123,11,168,127,113,104,146,242,216,114,9,7,241,215,155,150,233,15,196,11,89,101,4,43,255,109,127] -------------------------------------------------------------------------------- /transfer-sol/accounts/ringo.json: -------------------------------------------------------------------------------- 1 | [49,79,216,152,49,248,29,123,248,124,171,240,223,244,227,147,228,109,131,204,3,184,169,30,139,116,103,106,72,33,86,15,38,179,240,204,243,147,55,231,218,89,52,242,112,73,63,247,112,215,155,241,187,188,155,104,225,48,119,255,57,224,128,213] -------------------------------------------------------------------------------- /advanced-math/dist/program/calculator-keypair.json: -------------------------------------------------------------------------------- 1 | [101,205,55,74,247,241,0,109,167,79,105,77,106,157,12,15,237,84,65,244,239,55,144,75,85,10,177,145,214,17,199,34,19,205,23,158,93,82,171,72,150,102,18,113,240,27,49,244,171,64,250,145,12,9,69,199,238,219,70,153,174,160,214,184] -------------------------------------------------------------------------------- /hello-solana/dist/program/hello_solana-keypair.json: -------------------------------------------------------------------------------- 1 | [241,242,176,228,180,28,194,145,151,82,20,223,55,40,123,163,57,53,23,138,119,83,85,22,33,192,253,94,251,126,80,77,21,79,142,101,12,198,197,55,33,53,250,194,221,60,89,16,29,43,147,39,25,121,64,223,182,106,249,77,240,194,176,40] -------------------------------------------------------------------------------- /nfts/sell-nft/tests/keypairs/buyer1.json: -------------------------------------------------------------------------------- 1 | [238,92,30,199,165,249,239,85,211,92,154,189,154,105,214,239,95,102,73,213,112,118,44,221,62,159,192,64,232,101,238,132,145,50,151,16,236,72,7,164,56,30,206,208,253,174,84,218,48,142,164,220,125,222,180,160,220,235,118,239,78,108,225,23] -------------------------------------------------------------------------------- /pdas/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /transfer-sol/_dist/program/program-keypair.json: -------------------------------------------------------------------------------- 1 | [163,60,184,164,93,195,90,146,36,168,164,159,113,70,216,140,223,160,31,151,206,80,64,1,230,84,172,114,249,112,50,100,151,58,82,5,97,133,248,51,160,1,12,161,138,254,255,65,120,225,235,229,33,44,227,58,93,54,49,221,187,165,145,77] -------------------------------------------------------------------------------- /nfts/mint-nft/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/App.js: -------------------------------------------------------------------------------- 1 | import './App.css'; 2 | import Collection from './components/Collection'; 3 | 4 | function App() { 5 | return ( 6 |
7 | 8 |
9 | ); 10 | } 11 | 12 | export default App; 13 | -------------------------------------------------------------------------------- /nfts/sell-nft/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/tests/keypairs/buyer1.json: -------------------------------------------------------------------------------- 1 | [238,92,30,199,165,249,239,85,211,92,154,189,154,105,214,239,95,102,73,213,112,118,44,221,62,159,192,64,232,101,238,132,145,50,151,16,236,72,7,164,56,30,206,208,253,174,84,218,48,142,164,220,125,222,180,160,220,235,118,239,78,108,225,23] -------------------------------------------------------------------------------- /nfts/nft-marketplace/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["mocha", "chai"], 4 | "typeRoots": ["./node_modules/@types"], 5 | "lib": ["es2015"], 6 | "module": "commonjs", 7 | "target": "es6", 8 | "esModuleInterop": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | 6 | const root = ReactDOM.createRoot(document.getElementById('root')); 7 | root.render( 8 | 9 | 10 | 11 | ); -------------------------------------------------------------------------------- /math-stuff/src/sum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sum" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | borsh = "0.9.3" 8 | borsh-derive = "0.9.1" 9 | solana-program = "1.9.9" 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.9.9" 13 | solana-sdk = "1.9.9" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /math-stuff/src/square/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "square" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | borsh = "0.9.3" 8 | borsh-derive = "0.9.1" 9 | solana-program = "1.9.9" 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.9.9" 13 | solana-sdk = "1.9.9" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /transfer-sol/program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "program" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | borsh = "0.9.3" 8 | borsh-derive = "0.9.1" 9 | solana-program = "1.10.12" 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.10.12" 13 | solana-sdk = "1.10.12" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /advanced-math/src/calculator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "calculator" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | borsh = "0.9.3" 8 | borsh-derive = "0.9.1" 9 | solana-program = "1.9.9" 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.9.9" 13 | solana-sdk = "1.9.9" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/components/Nft.tsx: -------------------------------------------------------------------------------- 1 | 2 | interface NftProps { 3 | title: string, 4 | type: string, 5 | } 6 | 7 | function Nft(props: NftProps) { 8 | return( 9 |
10 |

{props.title}

11 |

{props.type}

12 |
13 | ); 14 | }; 15 | 16 | export default Nft; -------------------------------------------------------------------------------- /pdas/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.localnet] 4 | pdas = "BtSZDMEWUNjHi38dqbxf1qxBahf4vtUn8HurZxSE85px" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "localnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" 15 | -------------------------------------------------------------------------------- /nfts/mint-nft/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.devnet] 4 | mint_nft = "BQ31J31Mb1qK1dVjYyxq6Q6B2NrW72qaGQrTxuTPQJGM" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "devnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" 15 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/programs/nft-marketplace/src/lib.rs: -------------------------------------------------------------------------------- 1 | use anchor_lang::prelude::*; 2 | 3 | declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); 4 | 5 | #[program] 6 | pub mod nft_marketplace { 7 | use super::*; 8 | 9 | pub fn initialize(ctx: Context) -> Result<()> { 10 | Ok(()) 11 | } 12 | } 13 | 14 | #[derive(Accounts)] 15 | pub struct Initialize {} 16 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/util/rpc.ts: -------------------------------------------------------------------------------- 1 | 2 | export async function getNftsMinted() { 3 | return [ 4 | { 5 | title: "Test #1", 6 | type: "Rare", 7 | }, 8 | { 9 | title: "Test #2", 10 | type: "Not Rare", 11 | }, 12 | { 13 | title: "Test #3", 14 | type: "Rarest!", 15 | }, 16 | ] 17 | } -------------------------------------------------------------------------------- /nfts/nft-marketplace/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.devnet] 4 | nft_marketplace = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "devnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" 15 | -------------------------------------------------------------------------------- /hello-solana/src/program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello-solana" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | solana-program = "1.9.9" 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.9.9" 13 | solana-sdk = "1.9.9" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /nfts/mint-nft-raw/util.ts: -------------------------------------------------------------------------------- 1 | import { Keypair } from '@solana/web3.js'; 2 | import fs from 'mz/fs'; 3 | 4 | 5 | export async function createKeypairFromFile( 6 | filePath: string, 7 | ): Promise { 8 | const secretKeyString = await fs.readFile(filePath, {encoding: 'utf8'}); 9 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 10 | return Keypair.fromSecretKey(secretKey); 11 | } -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/programs/nft-marketplace-live/src/lib.rs: -------------------------------------------------------------------------------- 1 | use anchor_lang::prelude::*; 2 | 3 | declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); 4 | 5 | #[program] 6 | pub mod nft_marketplace_live { 7 | use super::*; 8 | 9 | pub fn initialize(ctx: Context) -> Result<()> { 10 | Ok(()) 11 | } 12 | } 13 | 14 | #[derive(Accounts)] 15 | pub struct Initialize {} 16 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.devnet] 4 | nft_marketplace_live = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "devnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" 15 | -------------------------------------------------------------------------------- /nfts/mint-nft/assets/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "YouTube NFT", 3 | "symbol": "TUBE", 4 | "description": "A test for our NFT example.", 5 | "seller_fee_basis_points": 5, 6 | "external_url": "", 7 | "edition": "", 8 | "background_color": "000000", 9 | "image": "https://upload.wikimedia.org/wikipedia/en/thumb/3/3b/SpongeBob_SquarePants_character.svg/640px-SpongeBob_SquarePants_character.svg.png" 10 | } 11 | -------------------------------------------------------------------------------- /math-stuff/src/client/util.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | } from '@solana/web3.js'; 4 | import fs from 'mz/fs'; 5 | 6 | 7 | 8 | export async function createKeypairFromFile( 9 | filePath: string, 10 | ): Promise { 11 | const secretKeyString = await fs.readFile(filePath, {encoding: 'utf8'}); 12 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 13 | return Keypair.fromSecretKey(secretKey); 14 | } -------------------------------------------------------------------------------- /nfts/nft-collection/app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /pdas/programs/pdas/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pdas" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "pdas" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | -------------------------------------------------------------------------------- /nfts/mint-nft-raw/mint/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mint" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | solana-program = "1.10.26" 8 | spl-token = { version="3.3.0", features = [ "no-entrypoint" ] } 9 | spl-associated-token-account = { version="1.0.5", features = [ "no-entrypoint" ] } 10 | 11 | [dev-dependencies] 12 | solana-program-test = "1.10.26" 13 | solana-sdk = "1.10.26" 14 | 15 | [lib] 16 | crate-type = ["cdylib", "lib"] -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /nfts/sell-nft/tests/util.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import fs from 'mz/fs'; 3 | 4 | 5 | 6 | export async function createKeypairFromFile( 7 | filePath: string, 8 | ): Promise { 9 | const secretKeyString = await fs.readFile(filePath, {encoding: 'utf8'}); 10 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 11 | return anchor.web3.Keypair.fromSecretKey(secretKey); 12 | } -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/tests/util.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import fs from 'mz/fs'; 3 | 4 | 5 | 6 | export async function createKeypairFromFile( 7 | filePath: string, 8 | ): Promise { 9 | const secretKeyString = await fs.readFile(filePath, {encoding: 'utf8'}); 10 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 11 | return anchor.web3.Keypair.fromSecretKey(secretKey); 12 | } -------------------------------------------------------------------------------- /hello-solana/src/program/src/lib.rs: -------------------------------------------------------------------------------- 1 | use solana_program::{ 2 | account_info::AccountInfo, 3 | entrypoint, 4 | entrypoint::ProgramResult, 5 | msg, 6 | pubkey::Pubkey, 7 | }; 8 | 9 | 10 | entrypoint!(process_instruction); 11 | 12 | 13 | fn process_instruction( 14 | program_id: &Pubkey, 15 | accounts: &[AccountInfo], 16 | instruction_data: &[u8], 17 | ) -> ProgramResult { 18 | 19 | msg!("Hello Solana! (From Rust!)"); 20 | Ok(()) 21 | } -------------------------------------------------------------------------------- /nfts/sell-nft/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.devnet] 4 | mint_nft = "GREPj1wkRt5dh8NeyFa6AuL8fxsiSVk5eMvKBaW9SbQ3" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "devnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test-mint = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test-mint.ts" 15 | test-sell = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test-sell.ts" -------------------------------------------------------------------------------- /pdas/migrations/deploy.ts: -------------------------------------------------------------------------------- 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("@project-serum/anchor"); 6 | 7 | module.exports = async function (provider) { 8 | // Configure client to use the provider. 9 | anchor.setProvider(provider); 10 | 11 | // Add your deploy script here. 12 | }; 13 | -------------------------------------------------------------------------------- /nfts/mint-nft/migrations/deploy.ts: -------------------------------------------------------------------------------- 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("@project-serum/anchor"); 6 | 7 | module.exports = async function (provider) { 8 | // Configure client to use the provider. 9 | anchor.setProvider(provider); 10 | 11 | // Add your deploy script here. 12 | }; 13 | -------------------------------------------------------------------------------- /nfts/sell-nft/migrations/deploy.ts: -------------------------------------------------------------------------------- 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("@project-serum/anchor"); 6 | 7 | module.exports = async function (provider) { 8 | // Configure client to use the provider. 9 | anchor.setProvider(provider); 10 | 11 | // Add your deploy script here. 12 | }; 13 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/migrations/deploy.ts: -------------------------------------------------------------------------------- 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("@project-serum/anchor"); 6 | 7 | module.exports = async function (provider) { 8 | // Configure client to use the provider. 9 | anchor.setProvider(provider); 10 | 11 | // Add your deploy script here. 12 | }; 13 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/migrations/deploy.ts: -------------------------------------------------------------------------------- 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("@project-serum/anchor"); 6 | 7 | module.exports = async function (provider) { 8 | // Configure client to use the provider. 9 | anchor.setProvider(provider); 10 | 11 | // Add your deploy script here. 12 | }; 13 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/Anchor.toml: -------------------------------------------------------------------------------- 1 | [features] 2 | seeds = false 3 | [programs.localnet] 4 | nft_collection = "DTLBF55gymzA3jkWEZKud1KoHBX7aLvHxG7Qecp3pBi" 5 | 6 | [registry] 7 | url = "https://anchor.projectserum.com" 8 | 9 | [provider] 10 | cluster = "localnet" 11 | wallet = "/home/joec/.config/solana/id.json" 12 | 13 | [scripts] 14 | test-mint = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test-mint.ts" 15 | test-sell = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test-sell.ts" 16 | -------------------------------------------------------------------------------- /nfts/mint-nft-raw/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "native-sol", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "app": "ts-node ./app.ts" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@solana/buffer-layout": "^4.0.0", 13 | "@solana/spl-token": "^0.2.0", 14 | "@solana/web3.js": "^1.44.1", 15 | "mz": "^2.7.0", 16 | "ts-node": "^10.8.1", 17 | "yaml": "^2.1.1" 18 | }, 19 | "devDependencies": { 20 | "@types/mz": "^2.7.4" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nfts/sell-nft/programs/mint-nft/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mint-nft" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "mint_nft" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } 24 | anchor-spl = "0.24.2" -------------------------------------------------------------------------------- /nfts/mint-nft/programs/mint-nft/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mint-nft" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "mint_nft" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } 24 | anchor-spl = "0.24.2" 25 | -------------------------------------------------------------------------------- /solana-cli/solana_alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-glibc 2 | 3 | RUN apk update && apk upgrade -a &&\ 4 | apk add --update bash build-base wget curl nodejs npm eudev-dev &&\ 5 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -q &&\ 6 | mv root/.cargo $PWD/.cargo &&\ 7 | wget -o solana-release.tar.bz2 https://github.com/solana-labs/solana/releases/download/v1.10.6/solana-release-x86_64-unknown-linux-gnu.tar.bz2 &&\ 8 | tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2 9 | 10 | ENV PATH=$PWD/.cargo/bin:$PWD/solana-release/bin:$PATH -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust Solana Tutorial 2 | 3 | :movie_camera: [Check it out on YouTube!](https://www.youtube.com/playlist?list=PLUBKxx7QjtVnU3hkPc8GF1Jh4DE7cf4n1) 4 | 5 | ### Tutorial #1 6 | ``` 7 | solana-cli 8 | ``` 9 | 10 | ### Tutorial #2 11 | ``` 12 | hello-solana 13 | ``` 14 | 15 | ### Tutorial #3 16 | ``` 17 | math-stuff 18 | ``` 19 | 20 | ### Tutorial #4 21 | ``` 22 | advanced-math 23 | ``` 24 | 25 | ### Tutorial #5 26 | ``` 27 | transfer-sol 28 | ``` 29 | 30 | ### Tutorials #6 - #12 (Except #10) 31 | ``` 32 | nfts 33 | ``` 34 | 35 | ### \* Tutorial #10 36 | ``` 37 | pdas 38 | ``` 39 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/programs/nft-marketplace/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nft-marketplace" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "nft_marketplace" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } 24 | anchor-spl = "0.24.2" -------------------------------------------------------------------------------- /pdas/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2" 8 | }, 9 | "devDependencies": { 10 | "@types/bn.js": "^5.1.0", 11 | "@types/chai": "^4.3.0", 12 | "@types/mocha": "^9.0.0", 13 | "chai": "^4.3.4", 14 | "mocha": "^9.0.3", 15 | "prettier": "^2.6.2", 16 | "ts-mocha": "^10.0.0", 17 | "typescript": "^4.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nfts/mint-nft/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2" 8 | }, 9 | "devDependencies": { 10 | "@types/bn.js": "^5.1.0", 11 | "@types/chai": "^4.3.0", 12 | "@types/mocha": "^9.0.0", 13 | "chai": "^4.3.4", 14 | "mocha": "^9.0.3", 15 | "prettier": "^2.6.2", 16 | "ts-mocha": "^10.0.0", 17 | "typescript": "^4.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/programs/nft-collection/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nft-collection" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "nft_collection" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | anchor-spl = "0.24.2" 24 | mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } -------------------------------------------------------------------------------- /advanced-math/src/calculator/src/calculator.rs: -------------------------------------------------------------------------------- 1 | use borsh::{BorshDeserialize, BorshSerialize}; 2 | 3 | 4 | 5 | #[derive(BorshSerialize, BorshDeserialize, Debug)] 6 | pub struct CalculatorInstructions { 7 | operation: u32, 8 | operating_value: u32, 9 | } 10 | 11 | impl CalculatorInstructions { 12 | pub fn evaluate(self, value: u32) -> u32 { 13 | match &self.operation { 14 | 1 => value + &self.operating_value, 15 | 2 => value - &self.operating_value, 16 | 3 => value * &self.operating_value, 17 | _ => value * 0, 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /nfts/nft-marketplace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2" 8 | }, 9 | "devDependencies": { 10 | "@types/bn.js": "^5.1.0", 11 | "@types/chai": "^4.3.0", 12 | "@types/mocha": "^9.0.0", 13 | "chai": "^4.3.4", 14 | "mocha": "^9.0.3", 15 | "prettier": "^2.6.2", 16 | "ts-mocha": "^10.0.0", 17 | "typescript": "^4.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2" 8 | }, 9 | "devDependencies": { 10 | "@types/bn.js": "^5.1.0", 11 | "@types/chai": "^4.3.0", 12 | "@types/mocha": "^9.0.0", 13 | "chai": "^4.3.4", 14 | "mocha": "^9.0.3", 15 | "prettier": "^2.6.2", 16 | "ts-mocha": "^10.0.0", 17 | "typescript": "^4.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2" 8 | }, 9 | "devDependencies": { 10 | "chai": "^4.3.4", 11 | "mocha": "^9.0.3", 12 | "ts-mocha": "^8.0.0", 13 | "@types/bn.js": "^5.1.0", 14 | "@types/chai": "^4.3.0", 15 | "@types/mocha": "^9.0.0", 16 | "typescript": "^4.3.5", 17 | "prettier": "^2.6.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/programs/nft-marketplace-live/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nft-marketplace-live" 3 | version = "0.1.0" 4 | description = "Created with Anchor" 5 | edition = "2021" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "lib"] 9 | name = "nft_marketplace_live" 10 | 11 | [features] 12 | no-entrypoint = [] 13 | no-idl = [] 14 | no-log-ix-name = [] 15 | cpi = ["no-entrypoint"] 16 | default = [] 17 | 18 | [profile.release] 19 | overflow-checks = true 20 | 21 | [dependencies] 22 | anchor-lang = "0.24.2" 23 | mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } 24 | anchor-spl = "0.24.2" -------------------------------------------------------------------------------- /nfts/sell-nft/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", 4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" 5 | }, 6 | "dependencies": { 7 | "@project-serum/anchor": "^0.24.2", 8 | "mz": "^2.7.0" 9 | }, 10 | "devDependencies": { 11 | "@types/bn.js": "^5.1.0", 12 | "@types/chai": "^4.3.0", 13 | "@types/mocha": "^9.0.0", 14 | "chai": "^4.3.4", 15 | "mocha": "^9.0.3", 16 | "prettier": "^2.6.2", 17 | "ts-mocha": "^10.0.0", 18 | "typescript": "^4.3.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /nfts/nft-marketplace/tests/nft-marketplace.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import { Program } from "@project-serum/anchor"; 3 | import { NftMarketplace } from "../target/types/nft_marketplace"; 4 | 5 | describe("nft-marketplace", () => { 6 | // Configure the client to use the local cluster. 7 | anchor.setProvider(anchor.AnchorProvider.env()); 8 | 9 | const program = anchor.workspace.NftMarketplace as Program; 10 | 11 | it("Is initialized!", async () => { 12 | // Add your test here. 13 | const tx = await program.methods.initialize().rpc(); 14 | console.log("Your transaction signature", tx); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /nfts/nft-marketplace-live/tests/nft-marketplace-live.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import { Program } from "@project-serum/anchor"; 3 | import { NftMarketplaceLive } from "../target/types/nft_marketplace_live"; 4 | 5 | describe("nft-marketplace-live", () => { 6 | // Configure the client to use the local cluster. 7 | anchor.setProvider(anchor.AnchorProvider.env()); 8 | 9 | const program = anchor.workspace.NftMarketplaceLive as Program; 10 | 11 | it("Is initialized!", async () => { 12 | // Add your test here. 13 | const tx = await program.methods.initialize().rpc(); 14 | console.log("Your transaction signature", tx); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hello-solana/README.md: -------------------------------------------------------------------------------- 1 | # Hello Solana 2 | 3 | Based on Solana Labs' Hello World example. 4 | 5 | ### Config 6 | 7 | ```shell 8 | solana-keygen new --no-bip39-passphrase 9 | solana config set --keypair /root/.config/solana/id.json 10 | solana config set --url http://api.devnet.solana.com 11 | 12 | solana airdrop 1 13 | 14 | npm install 15 | npm run build:program-rust 16 | solana program deploy dist/program/hello_solana.so 17 | npm run start 18 | 19 | solana program show --programs 20 | 21 | solana program close 22 | ``` 23 | 24 | ### Docker 25 | 26 | Alpine Docker container with `glibc`. Installing a few libs including `node`, `npm`, & `rust`. 27 | Uses `npm install` to build the app and the `solana` CLI to deploy it on-chain from Docker! 28 | 29 | ```shell 30 | network: devnet 31 | ``` -------------------------------------------------------------------------------- /math-stuff/src/client/sum.ts: -------------------------------------------------------------------------------- 1 | import * as borsh from 'borsh'; 2 | import * as math from './math'; 3 | 4 | 5 | 6 | class MathStuffSum { 7 | sum = 0; 8 | constructor(fields: {sum: number} | undefined = undefined) { 9 | if (fields) { 10 | this.sum = fields.sum; 11 | } 12 | } 13 | } 14 | 15 | const MathStuffSumSchema = new Map([ 16 | [MathStuffSum, {kind: 'struct', fields: [['sum', 'u32']]}], 17 | ]); 18 | 19 | const MATH_STUFF_SIZE = borsh.serialize( 20 | MathStuffSumSchema, 21 | new MathStuffSum(), 22 | ).length; 23 | 24 | 25 | 26 | async function main() { 27 | await math.example('sum', MATH_STUFF_SIZE); 28 | } 29 | 30 | 31 | main().then( 32 | () => process.exit(), 33 | err => { 34 | console.error(err); 35 | process.exit(-1); 36 | }, 37 | ); -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/components/Collection.tsx: -------------------------------------------------------------------------------- 1 | import { FC, useEffect, useState } from 'react'; 2 | import Nft from './Nft'; 3 | import * as rpc from '../util/rpc'; 4 | 5 | function Collection() { 6 | 7 | const [collection, setCollection] = useState([]); 8 | 9 | const loadCollection = async () => { 10 | setCollection( 11 | await rpc.getNftsMinted() 12 | ); 13 | }; 14 | 15 | useEffect(() => { 16 | loadCollection(); 17 | }, []); 18 | 19 | return( 20 |
21 |

Test

22 | {/* {collection.map((nft, index) => { 23 | return 24 | })} */} 25 |
26 | ) 27 | }; 28 | 29 | export default Collection; -------------------------------------------------------------------------------- /math-stuff/src/client/square.ts: -------------------------------------------------------------------------------- 1 | import * as borsh from 'borsh'; 2 | import * as math from './math'; 3 | 4 | 5 | 6 | class MathStuffSquare { 7 | sum = 0; 8 | constructor(fields: {sum: number} | undefined = undefined) { 9 | if (fields) { 10 | this.sum = fields.sum; 11 | } 12 | } 13 | } 14 | 15 | const MathStuffSquareSchema = new Map([ 16 | [MathStuffSquare, {kind: 'struct', fields: [['square', 'u32']]}], 17 | ]); 18 | 19 | const MATH_STUFF_SIZE = borsh.serialize( 20 | MathStuffSquareSchema, 21 | new MathStuffSquare(), 22 | ).length; 23 | 24 | 25 | 26 | async function main() { 27 | await math.example('square', MATH_STUFF_SIZE); 28 | } 29 | 30 | main().then( 31 | () => process.exit(), 32 | err => { 33 | console.error(err); 34 | process.exit(-1); 35 | }, 36 | ); -------------------------------------------------------------------------------- /nfts/sell-nft/programs/mint-nft/src/lib.rs: -------------------------------------------------------------------------------- 1 | use anchor_lang::prelude::*; 2 | 3 | pub mod mint; 4 | pub mod sell; 5 | 6 | use mint::*; 7 | use sell::*; 8 | 9 | 10 | declare_id!("GREPj1wkRt5dh8NeyFa6AuL8fxsiSVk5eMvKBaW9SbQ3"); 11 | 12 | 13 | #[program] 14 | pub mod mint_nft { 15 | use super::*; 16 | 17 | pub fn mint( 18 | ctx: Context, 19 | metadata_title: String, 20 | metadata_symbol: String, 21 | metadata_uri: String, 22 | ) -> Result<()> { 23 | mint::mint( 24 | ctx, 25 | metadata_title, 26 | metadata_symbol, 27 | metadata_uri, 28 | ) 29 | } 30 | 31 | pub fn sell( 32 | ctx: Context, 33 | sale_lamports: u64 34 | ) -> Result<()> { 35 | sell::sell( 36 | ctx, 37 | sale_lamports, 38 | ) 39 | } 40 | } -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/programs/nft-collection/src/lib.rs: -------------------------------------------------------------------------------- 1 | use anchor_lang::prelude::*; 2 | 3 | pub mod mint; 4 | pub mod sell; 5 | 6 | use mint::*; 7 | use sell::*; 8 | 9 | 10 | declare_id!("DTLBF55gymzA3jkWEZKud1KoHBX7aLvHxG7Qecp3pBi"); 11 | 12 | 13 | #[program] 14 | pub mod nft_collection { 15 | use super::*; 16 | 17 | pub fn mint( 18 | ctx: Context, 19 | metadata_title: String, 20 | metadata_symbol: String, 21 | metadata_uri: String, 22 | ) -> Result<()> { 23 | mint::mint( 24 | ctx, 25 | metadata_title, 26 | metadata_symbol, 27 | metadata_uri, 28 | ) 29 | } 30 | 31 | pub fn sell( 32 | ctx: Context, 33 | sale_lamports: u64 34 | ) -> Result<()> { 35 | sell::sell( 36 | ctx, 37 | sale_lamports, 38 | ) 39 | } 40 | } -------------------------------------------------------------------------------- /hello-solana/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-glibc 2 | 3 | RUN apk update && apk upgrade -a &&\ 4 | apk add --update bash build-base wget curl nodejs npm eudev-dev &&\ 5 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -q &&\ 6 | mv root/.cargo $PWD/.cargo &&\ 7 | wget -o solana-release.tar.bz2 https://github.com/solana-labs/solana/releases/download/v1.10.6/solana-release-x86_64-unknown-linux-gnu.tar.bz2 &&\ 8 | tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2 9 | 10 | ENV PATH=$PWD/.cargo/bin:$PWD/solana-release/bin:$PATH 11 | 12 | RUN solana-keygen new --no-bip39-passphrase &&\ 13 | solana config set --keypair /root/.config/solana/id.json &&\ 14 | solana config set --url http://api.devnet.solana.com &&\ 15 | solana airdrop 2 16 | 17 | COPY src src 18 | COPY package.json package.json 19 | 20 | RUN npm install &&\ 21 | npm run build:program &&\ 22 | solana program deploy dist/program/hello_solana.so 23 | 24 | ENTRYPOINT npm run start -------------------------------------------------------------------------------- /math-stuff/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-glibc 2 | 3 | RUN apk update && apk upgrade -a &&\ 4 | apk add --update bash build-base wget curl nodejs npm eudev-dev &&\ 5 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -q &&\ 6 | mv root/.cargo $PWD/.cargo &&\ 7 | wget -o solana-release.tar.bz2 https://github.com/solana-labs/solana/releases/download/v1.10.6/solana-release-x86_64-unknown-linux-gnu.tar.bz2 &&\ 8 | tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2 9 | 10 | ENV PATH=$PWD/.cargo/bin:$PWD/solana-release/bin:$PATH 11 | 12 | RUN solana-keygen new --no-bip39-passphrase &&\ 13 | solana config set --keypair /root/.config/solana/id.json &&\ 14 | solana config set --url http://api.devnet.solana.com &&\ 15 | solana airdrop 2 16 | 17 | COPY src src 18 | COPY package.json package.json 19 | 20 | RUN npm install &&\ 21 | npm run build:program &&\ 22 | solana program deploy dist/program/hello_solana.so 23 | 24 | ENTRYPOINT npm run start -------------------------------------------------------------------------------- /transfer-sol/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rust-p2p", 3 | "version": "1.0.0", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/Coding-and-Crypto/Rust-Solana-Tutorial.git" 8 | }, 9 | "scripts": { 10 | "clean": "./_cicd/cicd.sh clean", 11 | "reset": "./_cicd/cicd.sh reset", 12 | "build": "./_cicd/cicd.sh build", 13 | "deploy": "./_cicd/cicd.sh deploy", 14 | "reset-and-build": "./_cicd/cicd.sh reset-and-build", 15 | "simulation": "ts-node ./client/main.ts" 16 | }, 17 | "dependencies": { 18 | "@solana/web3.js": "^1.33.0", 19 | "buffer-layout": "^1.2.2" 20 | }, 21 | "devDependencies": { 22 | "@tsconfig/recommended": "^1.0.1", 23 | "@types/node": "^15.6.1", 24 | "ts-node": "^10.0.0", 25 | "typescript": "^4.2.4", 26 | "prettier": "^2.3.0" 27 | }, 28 | "engines": { 29 | "node": ">=14.0.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /nfts/nft-collection/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nft-collection", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.4", 7 | "@testing-library/react": "^13.3.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-scripts": "5.0.1", 12 | "typescript": "^4.7.4", 13 | "web-vitals": "^2.1.4" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ] 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /hello-solana/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-solana", 3 | "version": "1.0.0", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/Coding-and-Crypto/Rust-Solana-Tutorial.git" 8 | }, 9 | "scripts": { 10 | "start": "ts-node src/client/main.ts", 11 | "clean": "npm run clean:program", 12 | "build:program": "cargo build-bpf --manifest-path=./src/program/Cargo.toml --bpf-out-dir=dist/program", 13 | "clean:program": "cargo clean --manifest-path=./src/program/Cargo.toml && rm -rf ./dist", 14 | "test:program": "cargo test-bpf --manifest-path=./src/program/Cargo.toml" 15 | }, 16 | "dependencies": { 17 | "@solana/web3.js": "^1.37.1", 18 | "mz": "^2.7.0" 19 | }, 20 | "devDependencies": { 21 | "@tsconfig/recommended": "^1.0.1", 22 | "@types/mz": "^2.7.2", 23 | "ts-node": "^10.0.0", 24 | "typescript": "^4.0.5" 25 | }, 26 | "engines": { 27 | "node": ">=14.0.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /transfer-sol/README.md: -------------------------------------------------------------------------------- 1 | # Transfer SOL 2 | 3 | Simple example of transferring lamports (SOL). 4 | 5 | ### Creating the example keypairs: 6 | 7 | ```shell 8 | solana-keygen new --no-bip39-passphrase -o transfer-sol/accounts/ringo.json 9 | ``` 10 | 11 | ### Viewing their public keys: 12 | 13 | ```shell 14 | solana-keygen pubkey transfer-sol/accounts/george.json 15 | ``` 16 | 17 | ```shell 18 | Ringo: 3c5di8sz3rkag4LBLpjMxiMo7fAnPDMuyRQB6o4L4G1r 19 | George: FmLBYcNq1PYHsrtBVK4byrwjeqYtTFtLL6GjvYy4fpCM 20 | Paul: 2dw4Ff2P9NfNqL2eCCMKmh4wNunhsvzNTGxMZJEVHtSA 21 | John: 2AXzcKA3cXr1SMmGESTkP8pqx232njXQBCJJPJCb9vfJ 22 | ``` 23 | 24 | ### Airdropping: 25 | 26 | ```shell 27 | solana airdrop --keypair transfer-sol/accounts/john.json 2 28 | ``` 29 | 30 | ### Viewing their balances: 31 | 32 | ```shell 33 | solana account 34 | ``` 35 | 36 | ## Run the example: 37 | 38 | In one terminal: 39 | ```shell 40 | npm run reset-and-build 41 | npm run simulation 42 | ``` 43 | 44 | In another terminal: 45 | ```shell 46 | solana logs | grep " invoke" -A 7 47 | ``` -------------------------------------------------------------------------------- /nfts/README.md: -------------------------------------------------------------------------------- 1 | # NFTs! 2 | 3 | We use Anchor - both for the client-side and on-chain code - in each example in this repository except for `mint-nft-raw`. That one is just Solana crates & libs. 4 | 5 | | Repository | Description | 6 | | ------------------ | ---------------------------------------------------------- | 7 | | `mint-nft-raw` | Mint an NFT to your local wallet using **only Solana crates & packages**. | 8 | | `mint-nft` | Mint an NFT to your local wallet using **Anchor**, including metadata using **Metaplex**. | 9 | | `sell-nft` | Sell one of your NFTs to another Solana wallet. Receive SOl from & transfer NFT to buyer. | 10 | | `nft-collection` | Sample application using Metaplex's Candy Machine. Demonstrates minting & selling NFTs, driveable from the UI. | 11 | | `nft-marketplace` | Sample application demonstrating use of Solana account model to simulate a small NFT marketplace with bidding & selling of NFTs. | 12 | | `nft-marketplace-live` | Same as previous example but with live price changes based on transactions from a particular NFT. | 13 | 14 | 15 | ## How NFTs Work 16 | ![](how_nfts_work.jpg) 17 | ![](nfts_more_detail.jpg) -------------------------------------------------------------------------------- /advanced-math/src/calculator/src/lib.rs: -------------------------------------------------------------------------------- 1 | use borsh::{BorshDeserialize, BorshSerialize}; 2 | use solana_program::{ 3 | account_info::{next_account_info, AccountInfo}, 4 | entrypoint, 5 | entrypoint::ProgramResult, 6 | msg, 7 | program_error::ProgramError, 8 | pubkey::Pubkey, 9 | }; 10 | use crate::calculator::CalculatorInstructions; 11 | 12 | mod calculator; 13 | 14 | 15 | 16 | #[derive(BorshSerialize, BorshDeserialize, Debug)] 17 | pub struct Calculator { 18 | pub value: u32, 19 | } 20 | 21 | 22 | entrypoint!(process_instruction); 23 | 24 | 25 | fn process_instruction( 26 | program_id: &Pubkey, 27 | accounts: &[AccountInfo], 28 | instruction_data: &[u8], 29 | ) -> ProgramResult { 30 | 31 | let accounts_iter = &mut accounts.iter(); 32 | let account = next_account_info(accounts_iter)?; 33 | 34 | if account.owner != program_id { 35 | msg!("Account does not have the correct program id"); 36 | return Err(ProgramError::IncorrectProgramId); 37 | } 38 | 39 | let mut calc = Calculator::try_from_slice(&account.data.borrow())?; 40 | 41 | let calculator_instructions = CalculatorInstructions::try_from_slice(&instruction_data)?; 42 | 43 | calc.value = calculator_instructions.evaluate(calc.value); 44 | 45 | calc.serialize(&mut &mut account.data.borrow_mut()[..])?; 46 | msg!("Value is now: {}", calc.value); 47 | 48 | Ok(()) 49 | } -------------------------------------------------------------------------------- /transfer-sol/program/src/lib.rs: -------------------------------------------------------------------------------- 1 | use { 2 | std::convert::TryInto, 3 | solana_program::{ 4 | account_info::{ 5 | next_account_info, AccountInfo 6 | }, 7 | entrypoint, 8 | entrypoint::ProgramResult, 9 | msg, 10 | program::invoke, 11 | program_error::ProgramError, 12 | pubkey::Pubkey, 13 | system_instruction, 14 | }, 15 | }; 16 | 17 | 18 | entrypoint!(process_instruction); 19 | 20 | 21 | pub fn process_instruction( 22 | _program_id: &Pubkey, 23 | accounts: &[AccountInfo], 24 | input: &[u8], 25 | ) -> ProgramResult { 26 | 27 | let accounts_iter = &mut accounts.iter(); 28 | let payer = next_account_info(accounts_iter)?; 29 | let payee = next_account_info(accounts_iter)?; 30 | 31 | let amount = input 32 | .get(..8) 33 | .and_then(|slice| slice.try_into().ok()) 34 | .map(u64::from_le_bytes) 35 | .ok_or(ProgramError::InvalidInstructionData)?; 36 | 37 | // let amount = i32::try_from_slice(input); 38 | 39 | msg!("Received request to transfer {:?} lamports from {:?} to {:?}.", 40 | amount, payer.key, payee.key); 41 | msg!(" Processing transfer..."); 42 | 43 | // Transfer from PAYER to PAYEE a specific amount: 44 | invoke( 45 | &system_instruction::transfer(payer.key, payee.key, amount), 46 | &[payer.clone(), payee.clone()], 47 | )?; 48 | 49 | msg!("Transfer completed successfully."); 50 | Ok(()) 51 | } -------------------------------------------------------------------------------- /math-stuff/README.md: -------------------------------------------------------------------------------- 1 | # Math Stuff 2 | 3 | Working with data accounts on Solana. 4 | 5 | ![](solana-accounts.jpg) 6 | 7 | ## How it works: 8 | 9 | ### Rust (On-Chain Solana Programs) 10 | 11 | First we write the on-chain programs that will handle the business logic of whatever it is we want to do. 12 | 13 | In this case, we are just performing some math calculations on some account data. 14 | 15 | These are deployed to the Solana network, and each one lives in an `executable program` - which is also called an `executable account`. 16 | 17 | They store data - such as schema details - but not your traditional persisted data. 18 | 19 | ### TypeScript (Client) 20 | 21 | Next we invoke the on-chain programs by using the same local keypair (the one we used to deploy our Rust programs) to create 22 | an account that will transact with the math programs we deployed. 23 | 24 | This is our client account. 25 | 26 | **The important part here is that the account we just created is actually owned by the program we intend to hit**. 27 | 28 | Steps: 29 | - Get the local Keypair used to deploy the math programs. 30 | - Get the intended program's ID. 31 | - Create an account under the same program ID (also using the local Keypair). This account will store data of it's own. 32 | - **Now that we have an account that shares the same program ID (owner), the on-chain program can modify the account's data**. 33 | - Ping the program and trigger the math calculation, using our created account, to modify our created account's data. 34 | -------------------------------------------------------------------------------- /advanced-math/src/client/util.ts: -------------------------------------------------------------------------------- 1 | import { Keypair } from '@solana/web3.js'; 2 | import fs from 'mz/fs'; 3 | import * as BufferLayout from '@solana/buffer-layout'; 4 | import { Buffer } from 'buffer'; 5 | 6 | 7 | 8 | export async function createKeypairFromFile( 9 | filePath: string, 10 | ): Promise { 11 | const secretKeyString = await fs.readFile(filePath, {encoding: 'utf8'}); 12 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 13 | return Keypair.fromSecretKey(secretKey); 14 | } 15 | 16 | 17 | export async function getStringForInstruction( 18 | operation: number, operating_value: number) { 19 | 20 | if (operation == 0) { 21 | return "reset the example."; 22 | } else if (operation == 1) { 23 | return `add: ${operating_value}`; 24 | } else if (operation == 2) { 25 | return `subtract: ${operating_value}`; 26 | } else if (operation == 3) { 27 | return `multiply by: ${operating_value}`; 28 | } 29 | } 30 | 31 | 32 | export async function createCalculatorInstructions( 33 | operation: number, operating_value: number): Promise { 34 | 35 | const bufferLayout: BufferLayout.Structure = BufferLayout.struct( 36 | [ 37 | BufferLayout.u32('operation'), 38 | BufferLayout.u32('operating_value'), 39 | ] 40 | ); 41 | 42 | const buffer = Buffer.alloc(bufferLayout.span); 43 | bufferLayout.encode({ 44 | operation: operation, 45 | operating_value: operating_value, 46 | }, buffer); 47 | 48 | return buffer; 49 | } -------------------------------------------------------------------------------- /math-stuff/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "math-stuff", 3 | "version": "1.0.0", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/Coding-and-Crypto/Rust-Solana-Tutorial.git" 8 | }, 9 | "scripts": { 10 | "clean": "./scripts/cicd.sh clean", 11 | "reset": "./scripts/cicd.sh reset", 12 | "build": "./scripts/cicd.sh build", 13 | "deploy": "./scripts/cicd.sh deploy", 14 | "reset-and-build": "./scripts/cicd.sh reset-and-build", 15 | "example:sum": "ts-node ./src/client/sum.ts", 16 | "example:square": "ts-node ./src/client/square.ts" 17 | }, 18 | "dependencies": { 19 | "@solana/web3.js": "^1.33.0", 20 | "borsh": "^0.7.0", 21 | "mz": "^2.7.0", 22 | "yaml": "^1.10.2" 23 | }, 24 | "devDependencies": { 25 | "@tsconfig/recommended": "^1.0.1", 26 | "@types/eslint": "^8.2.2", 27 | "@types/eslint-plugin-prettier": "^3.1.0", 28 | "@types/mz": "^2.7.2", 29 | "@types/prettier": "^2.1.5", 30 | "@types/yaml": "^1.9.7", 31 | "@typescript-eslint/eslint-plugin": "^4.6.0", 32 | "@typescript-eslint/parser": "^4.6.0", 33 | "eslint": "^7.12.1", 34 | "eslint-config-prettier": "^6.15.0", 35 | "eslint-plugin-prettier": "^4.0.0", 36 | "prettier": "^2.1.2", 37 | "start-server-and-test": "^1.11.6", 38 | "ts-node": "^10.0.0", 39 | "typescript": "^4.0.5" 40 | }, 41 | "engines": { 42 | "node": ">=14.0.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /advanced-math/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "advanced-math", 3 | "version": "1.0.0", 4 | "description": "", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/Coding-and-Crypto/Rust-Solana-Tutorial.git" 8 | }, 9 | "scripts": { 10 | "clean": "./scripts/cicd.sh clean", 11 | "reset": "./scripts/cicd.sh reset", 12 | "build": "./scripts/cicd.sh build", 13 | "deploy": "./scripts/cicd.sh deploy", 14 | "reset-and-build": "./scripts/cicd.sh reset-and-build", 15 | "example": "ts-node ./src/client/calculator.ts" 16 | }, 17 | "dependencies": { 18 | "@solana/buffer-layout": "^4.0.0", 19 | "@solana/web3.js": "^1.33.0", 20 | "borsh": "^0.7.0", 21 | "buffer": "^6.0.3", 22 | "mz": "^2.7.0", 23 | "yaml": "^1.10.2" 24 | }, 25 | "devDependencies": { 26 | "@tsconfig/recommended": "^1.0.1", 27 | "@types/eslint": "^8.2.2", 28 | "@types/eslint-plugin-prettier": "^3.1.0", 29 | "@types/mz": "^2.7.2", 30 | "@types/prettier": "^2.1.5", 31 | "@types/yaml": "^1.9.7", 32 | "@typescript-eslint/eslint-plugin": "^4.6.0", 33 | "@typescript-eslint/parser": "^4.6.0", 34 | "eslint": "^7.12.1", 35 | "eslint-config-prettier": "^6.15.0", 36 | "eslint-plugin-prettier": "^4.0.0", 37 | "prettier": "^2.1.2", 38 | "start-server-and-test": "^1.11.6", 39 | "ts-node": "^10.0.0", 40 | "typescript": "^4.0.5" 41 | }, 42 | "engines": { 43 | "node": ">=14.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pdas/programs/pdas/src/lib.rs: -------------------------------------------------------------------------------- 1 | use anchor_lang::prelude::*; 2 | 3 | declare_id!("BtSZDMEWUNjHi38dqbxf1qxBahf4vtUn8HurZxSE85px"); 4 | 5 | #[program] 6 | pub mod pdas { 7 | use super::*; 8 | 9 | pub fn create_ledger( 10 | ctx: Context, 11 | color: String, 12 | ) -> Result<()> { 13 | 14 | let ledger_account = &mut ctx.accounts.ledger_account; 15 | ledger_account.color = color; 16 | ledger_account.balance = 0; 17 | 18 | Ok(()) 19 | } 20 | 21 | pub fn modify_ledger( 22 | ctx: Context, 23 | new_balance: u32, 24 | ) -> Result<()> { 25 | 26 | let ledger_account = &mut ctx.accounts.ledger_account; 27 | ledger_account.balance = new_balance; 28 | 29 | Ok(()) 30 | } 31 | } 32 | 33 | #[derive(Accounts)] 34 | #[instruction(color: String)] 35 | pub struct CreateLedger<'info> { 36 | #[account( 37 | init, 38 | payer = wallet, 39 | space = 82, 40 | seeds = [ 41 | wallet.key().as_ref(), 42 | b"_", 43 | color.as_ref(), 44 | ], 45 | bump 46 | )] 47 | pub ledger_account: Account<'info, Ledger>, 48 | #[account(mut)] 49 | pub wallet: Signer<'info>, 50 | pub system_program: Program<'info, System>, 51 | } 52 | 53 | #[derive(Accounts)] 54 | pub struct ModifyLedger<'info> { 55 | #[account(mut)] 56 | pub ledger_account: Account<'info, Ledger>, 57 | #[account(mut)] 58 | pub wallet: Signer<'info>, 59 | } 60 | 61 | #[account] 62 | pub struct Ledger { 63 | pub color: String, 64 | pub balance: u32, 65 | } -------------------------------------------------------------------------------- /math-stuff/src/sum/src/lib.rs: -------------------------------------------------------------------------------- 1 | use borsh::{BorshDeserialize, BorshSerialize}; 2 | use solana_program::{ 3 | account_info::{next_account_info, AccountInfo}, 4 | entrypoint, 5 | entrypoint::ProgramResult, 6 | msg, 7 | program_error::ProgramError, 8 | pubkey::Pubkey, 9 | }; 10 | 11 | 12 | #[derive(BorshSerialize, BorshDeserialize, Debug)] 13 | pub struct MathStuffSum { 14 | pub sum: u32, 15 | } 16 | 17 | 18 | entrypoint!(process_instruction); 19 | 20 | 21 | fn process_instruction( 22 | program_id: &Pubkey, 23 | accounts: &[AccountInfo], 24 | instruction_data: &[u8], 25 | ) -> ProgramResult { 26 | 27 | 28 | // Directly from Solana Hello World example: 29 | // 30 | // Iterating accounts is safer than indexing 31 | let accounts_iter = &mut accounts.iter(); 32 | 33 | // Get the account to say hello to 34 | let account = next_account_info(accounts_iter)?; 35 | 36 | // The account must be owned by the program in order to modify its data 37 | if account.owner != program_id { 38 | msg!("Account does not have the correct program id"); 39 | return Err(ProgramError::IncorrectProgramId); 40 | } 41 | 42 | msg!("Debug output:"); 43 | msg!("Account ID: {}", account.key); 44 | msg!("Executable?: {}", account.executable); 45 | msg!("Lamports: {:#?}", account.lamports); 46 | msg!("Debug output complete."); 47 | 48 | msg!("Adding 1 to sum..."); 49 | 50 | let mut math_stuff = MathStuffSum::try_from_slice(&account.data.borrow())?; 51 | math_stuff.sum += 1; 52 | math_stuff.serialize(&mut &mut account.data.borrow_mut()[..])?; 53 | 54 | msg!("Current sum is now: {}", math_stuff.sum); 55 | 56 | Ok(()) 57 | } -------------------------------------------------------------------------------- /math-stuff/src/square/src/lib.rs: -------------------------------------------------------------------------------- 1 | use borsh::{BorshDeserialize, BorshSerialize}; 2 | use solana_program::{ 3 | account_info::{next_account_info, AccountInfo}, 4 | entrypoint, 5 | entrypoint::ProgramResult, 6 | msg, 7 | program_error::ProgramError, 8 | pubkey::Pubkey, 9 | }; 10 | 11 | 12 | #[derive(BorshSerialize, BorshDeserialize, Debug)] 13 | pub struct MathStuffSquare { 14 | pub square: u32, 15 | } 16 | 17 | 18 | entrypoint!(process_instruction); 19 | 20 | 21 | fn process_instruction( 22 | program_id: &Pubkey, 23 | accounts: &[AccountInfo], 24 | instruction_data: &[u8], 25 | ) -> ProgramResult { 26 | 27 | 28 | // Directly from Solana Hello World example: 29 | // 30 | // Iterating accounts is safer than indexing 31 | let accounts_iter = &mut accounts.iter(); 32 | 33 | // Get the account to say hello to 34 | let account = next_account_info(accounts_iter)?; 35 | 36 | // The account must be owned by the program in order to modify its data 37 | if account.owner != program_id { 38 | msg!("Account does not have the correct program id"); 39 | return Err(ProgramError::IncorrectProgramId); 40 | } 41 | 42 | msg!("Debug output:"); 43 | msg!("Account ID: {}", account.key); 44 | msg!("Executable?: {}", account.executable); 45 | msg!("Lamports: {:#?}", account.lamports); 46 | msg!("Debug output complete."); 47 | 48 | msg!("Squaring value..."); 49 | 50 | let mut math_stuff = MathStuffSquare::try_from_slice(&account.data.borrow())?; 51 | math_stuff.square = math_stuff.square.pow(2); 52 | math_stuff.serialize(&mut &mut account.data.borrow_mut()[..])?; 53 | 54 | msg!("Current square is now: {}", math_stuff.square); 55 | 56 | Ok(()) 57 | } -------------------------------------------------------------------------------- /transfer-sol/_cicd/cicd.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | SOLANA_PROGRAMS=("program") 4 | 5 | case $1 in 6 | "reset") 7 | rm -rf ./node_modules 8 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 9 | if [[ $x != "Program" ]]; 10 | then 11 | solana program close $x; 12 | fi 13 | done 14 | for program in "${SOLANA_PROGRAMS[@]}"; do 15 | cargo clean --manifest-path=./$program/Cargo.toml 16 | done 17 | rm -rf _dist/program 18 | ;; 19 | "clean") 20 | rm -rf ./node_modules 21 | for program in "${SOLANA_PROGRAMS[@]}"; do 22 | cargo clean --manifest-path=./$program/Cargo.toml 23 | done;; 24 | "build") 25 | for program in "${SOLANA_PROGRAMS[@]}"; do 26 | cargo build-bpf --manifest-path=./$program/Cargo.toml --bpf-out-dir=./_dist/program 27 | done;; 28 | "deploy") 29 | for program in "${SOLANA_PROGRAMS[@]}"; do 30 | solana program deploy _dist/program/$program.so 31 | done;; 32 | "reset-and-build") 33 | rm -rf ./node_modules 34 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 35 | if [[ $x != "Program" ]]; 36 | then 37 | solana program close $x; 38 | fi 39 | done 40 | rm -rf _dist/program 41 | for program in "${SOLANA_PROGRAMS[@]}"; do 42 | cargo clean --manifest-path=./$program/Cargo.toml 43 | cargo build-bpf --manifest-path=./$program/Cargo.toml --bpf-out-dir=./_dist/program 44 | solana program deploy _dist/program/$program.so 45 | done 46 | npm install 47 | solana program show --programs 48 | ;; 49 | esac -------------------------------------------------------------------------------- /advanced-math/src/client/calculator.ts: -------------------------------------------------------------------------------- 1 | import * as borsh from 'borsh'; 2 | import * as math from './math'; 3 | 4 | 5 | 6 | // -------------------------------------------------------- 7 | 8 | /* 9 | Account Data 10 | */ 11 | 12 | class Calculator { 13 | value = 0; 14 | constructor(fields: {value: number} | undefined = undefined) { 15 | if (fields) { 16 | this.value = fields.value; 17 | } 18 | } 19 | } 20 | 21 | const CalculatorSchema = new Map([ 22 | [Calculator, {kind: 'struct', fields: [['value', 'u32']]}], 23 | ]); 24 | 25 | const CALCULATOR_SIZE = borsh.serialize( 26 | CalculatorSchema, 27 | new Calculator(), 28 | ).length; 29 | 30 | 31 | // -------------------------------------------------------- 32 | 33 | /* 34 | Instruction Data 35 | */ 36 | 37 | export class CalculatorInstructions { 38 | operation = 0; 39 | operating_value = 0; 40 | constructor(fields: {operation: number, operating_value: number} | undefined = undefined) { 41 | if (fields) { 42 | this.operation = fields.operation; 43 | this.operating_value = fields.operating_value; 44 | } 45 | } 46 | } 47 | 48 | export const CalculatorInstructionsSchema = new Map([ 49 | [CalculatorInstructions, {kind: 'struct', fields: [ 50 | ['operation', 'u32'], ['operating_value', 'u32'] 51 | ]}], 52 | ]); 53 | 54 | export const CALCULATOR_INSTRUCTIONS_SIZE = borsh.serialize( 55 | CalculatorInstructionsSchema, 56 | new CalculatorInstructions(), 57 | ).length; 58 | 59 | 60 | 61 | // -------------------------------------------------------- 62 | 63 | /* 64 | Main 65 | */ 66 | 67 | async function main() { 68 | await math.example('calculator', CALCULATOR_SIZE); 69 | } 70 | 71 | 72 | main().then( 73 | () => process.exit(), 74 | err => { 75 | console.error(err); 76 | process.exit(-1); 77 | }, 78 | ); -------------------------------------------------------------------------------- /nfts/nft-collection/app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /advanced-math/scripts/cicd.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | SOLANA_PROGRAMS=("calculator") 4 | 5 | case $1 in 6 | "reset") 7 | rm -rf ./node_modules 8 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 9 | if [[ $x != "Program" ]]; 10 | then 11 | solana program close $x; 12 | fi 13 | done 14 | for program in "${SOLANA_PROGRAMS[@]}"; do 15 | cargo clean --manifest-path=./src/$program/Cargo.toml 16 | done 17 | rm -rf dist/program 18 | ;; 19 | "clean") 20 | rm -rf ./node_modules 21 | for program in "${SOLANA_PROGRAMS[@]}"; do 22 | cargo clean --manifest-path=./src/$program/Cargo.toml 23 | done;; 24 | "build") 25 | for program in "${SOLANA_PROGRAMS[@]}"; do 26 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 27 | done;; 28 | "deploy") 29 | for program in "${SOLANA_PROGRAMS[@]}"; do 30 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 31 | solana program deploy dist/program/$program.so 32 | done;; 33 | "reset-and-build") 34 | rm -rf ./node_modules 35 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 36 | if [[ $x != "Program" ]]; 37 | then 38 | solana program close $x; 39 | fi 40 | done 41 | rm -rf dist/program 42 | for program in "${SOLANA_PROGRAMS[@]}"; do 43 | cargo clean --manifest-path=./src/$program/Cargo.toml 44 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 45 | solana program deploy dist/program/$program.so 46 | done 47 | npm install 48 | solana program show --programs 49 | ;; 50 | esac -------------------------------------------------------------------------------- /math-stuff/scripts/cicd.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | SOLANA_PROGRAMS=("sum" "square") 4 | 5 | case $1 in 6 | "reset") 7 | rm -rf ./node_modules 8 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 9 | if [[ $x != "Program" ]]; 10 | then 11 | solana program close $x; 12 | fi 13 | done 14 | for program in "${SOLANA_PROGRAMS[@]}"; do 15 | cargo clean --manifest-path=./src/$program/Cargo.toml 16 | done 17 | rm -rf dist/program 18 | ;; 19 | "clean") 20 | rm -rf ./node_modules 21 | for program in "${SOLANA_PROGRAMS[@]}"; do 22 | cargo clean --manifest-path=./src/$program/Cargo.toml 23 | done;; 24 | "build") 25 | for program in "${SOLANA_PROGRAMS[@]}"; do 26 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 27 | done;; 28 | "deploy") 29 | for program in "${SOLANA_PROGRAMS[@]}"; do 30 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 31 | solana program deploy dist/program/$program.so 32 | done;; 33 | "reset-and-build") 34 | rm -rf ./node_modules 35 | for x in $(solana program show --programs | awk 'RP==0 {print $1}'); do 36 | if [[ $x != "Program" ]]; 37 | then 38 | solana program close $x; 39 | fi 40 | done 41 | rm -rf dist/program 42 | for program in "${SOLANA_PROGRAMS[@]}"; do 43 | cargo clean --manifest-path=./src/$program/Cargo.toml 44 | cargo build-bpf --manifest-path=./src/$program/Cargo.toml --bpf-out-dir=./dist/program 45 | solana program deploy dist/program/$program.so 46 | done 47 | npm install 48 | solana program show --programs 49 | ;; 50 | esac -------------------------------------------------------------------------------- /hello-solana/src/client/main.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | Connection, 4 | PublicKey, 5 | LAMPORTS_PER_SOL, 6 | TransactionInstruction, 7 | Transaction, 8 | sendAndConfirmTransaction, 9 | } from '@solana/web3.js'; 10 | import fs from 'mz/fs'; 11 | import path from 'path'; 12 | 13 | 14 | /* 15 | Our keypair we used to create the on-chain Rust program 16 | */ 17 | const PROGRAM_KEYPAIR_PATH = path.join( 18 | path.resolve(__dirname, '../../dist/program'), 19 | 'hello_solana-keypair.json' 20 | ); 21 | 22 | 23 | async function main() { 24 | 25 | console.log("Launching client..."); 26 | 27 | /* 28 | Connect to Solana DEV net 29 | */ 30 | let connection = new Connection('https://api.devnet.solana.com', 'confirmed'); 31 | 32 | /* 33 | Get our program's public key 34 | */ 35 | const secretKeyString = await fs.readFile(PROGRAM_KEYPAIR_PATH, {encoding: 'utf8'}); 36 | const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); 37 | const programKeypair = Keypair.fromSecretKey(secretKey); 38 | let programId: PublicKey = programKeypair.publicKey; 39 | 40 | /* 41 | Generate an account (keypair) to transact with our program 42 | */ 43 | const triggerKeypair = Keypair.generate(); 44 | const airdropRequest = await connection.requestAirdrop( 45 | triggerKeypair.publicKey, 46 | LAMPORTS_PER_SOL, 47 | ); 48 | await connection.confirmTransaction(airdropRequest); 49 | 50 | /* 51 | Conduct a transaction with our program 52 | */ 53 | console.log('--Pinging Program ', programId.toBase58()); 54 | const instruction = new TransactionInstruction({ 55 | keys: [{pubkey: triggerKeypair.publicKey, isSigner: false, isWritable: true}], 56 | programId, 57 | data: Buffer.alloc(0), 58 | }); 59 | await sendAndConfirmTransaction( 60 | connection, 61 | new Transaction().add(instruction), 62 | [triggerKeypair], 63 | ); 64 | } 65 | 66 | 67 | main().then( 68 | () => process.exit(), 69 | err => { 70 | console.error(err); 71 | process.exit(-1); 72 | }, 73 | ); 74 | -------------------------------------------------------------------------------- /solana-cli/README.md: -------------------------------------------------------------------------------- 1 | # Solana CLI 2 | 3 | ## Install & Setup: 4 | 5 | Install the Solana Tool Suite by following [these instructions](https://docs.solana.com/cli/install-solana-cli-tools). 6 | 7 | Once the CLI is installed, we must create an account. We do this by generating a new **public/private key pair**. 8 | ```shell 9 | solana-keygen new 10 | ``` 11 | 12 | Once we do that, we have to configure our Solana CLI client to use our new account. 13 | ```shell 14 | solana config set --keypair /root/.config/solana/id.json 15 | ``` 16 | 17 | And now we just need to bind our client to a Solana network. 18 | ```shell 19 | solana config set --url 20 | ``` 21 | ```shell 22 | (dev net -- development) https://api.devnet.solana.com 23 | (test net -- staging) https://api.testnet.solana.com 24 | (main net -- production) https://api.mainnet-beta.solana.com 25 | ``` 26 | 27 | ## Exploring: 28 | 29 | **You can see all commands supported by the Solana CLI by just entering:** 30 | ```shell 31 | solana 32 | ``` 33 | 34 | Here's a few examples: 35 | 36 | To deploy applications on Solana, you need to pay `rent`. This costs a small amount of `lamports`(SOL). On the `dev` network, you can request an `airdrop` of "test money" to deploy to the dev net: 37 | ```shell 38 | solana airdrop 1 39 | ``` 40 | 41 | Check the balance of your account: 42 | ```shell 43 | solana balance 44 | ``` 45 | 46 | ## The Dockerfile: 47 | 48 | Provided is a Dockerfile used to create the following image: [jpcaulfi/solana-alpine](https://hub.docker.com/repository/docker/jpcaulfi/solana-alpine). 49 | 50 | You can leverage this image to create a Docker container to conduct Solana business out of - such as deploying and even hosting/running an application. 51 | 52 | This image contains: 53 | ```shell 54 | node rust solana 55 | ``` 56 | 57 | You can run these commands in the container or write a Dockerfile: 58 | ```shell 59 | solana-keygen new --no-bip39-passphrase 60 | solana config set --keypair /root/.config/solana/id.json 61 | solana config set --url http://api.devnet.solana.com 62 | solana airdrop 2 63 | ``` -------------------------------------------------------------------------------- /nfts/sell-nft/tests/test-sell.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | // ** Comment this to use solpg imported IDL ** 3 | import { 4 | createKeypairFromFile, 5 | } from './util'; 6 | import { MintNft } from "../target/types/mint_nft"; 7 | 8 | 9 | describe("sell-nft", async () => { 10 | 11 | 12 | const provider = anchor.AnchorProvider.env() 13 | const wallet = provider.wallet as anchor.Wallet; 14 | anchor.setProvider(provider); 15 | 16 | // ** Un-comment this to use solpg imported IDL ** 17 | // const program = new anchor.Program( 18 | // require("../solpg/idl.json"), 19 | // new anchor.web3.PublicKey("H2UJjAQTuVJYhaBhh6GD2KaprLBTp1vhP2aaHioya5NM"), 20 | // ); 21 | // ** Comment this to use solpg imported IDL ** 22 | const program = anchor.workspace.MintNft as anchor.Program; 23 | 24 | 25 | it("Sell!", async () => { 26 | 27 | // Testing constants 28 | 29 | const saleAmount = 1 * anchor.web3.LAMPORTS_PER_SOL; 30 | const mint: anchor.web3.PublicKey = new anchor.web3.PublicKey( 31 | "59UQbpn69GKiTZajEy6y732AFYB3HGY7q1ymdj2qomS2" 32 | ); 33 | const buyer: anchor.web3.Keypair = await createKeypairFromFile(__dirname + "/keypairs/buyer1.json"); 34 | console.log(`Buyer public key: ${buyer.publicKey}`); 35 | 36 | // Derive the associated token account address for owner & buyer 37 | 38 | const ownerTokenAddress = await anchor.utils.token.associatedAddress({ 39 | mint: mint, 40 | owner: wallet.publicKey 41 | }); 42 | const buyerTokenAddress = await anchor.utils.token.associatedAddress({ 43 | mint: mint, 44 | owner: buyer.publicKey, 45 | }); 46 | console.log(`Request to sell NFT: ${mint} for ${saleAmount} lamports.`); 47 | console.log(`Owner's Token Address: ${ownerTokenAddress}`); 48 | console.log(`Buyer's Token Address: ${buyerTokenAddress}`); 49 | 50 | // Transact with the "sell" function in our on-chain program 51 | 52 | await program.methods.sell( 53 | new anchor.BN(saleAmount) 54 | ) 55 | .accounts({ 56 | mint: mint, 57 | ownerTokenAccount: ownerTokenAddress, 58 | ownerAuthority: wallet.publicKey, 59 | buyerTokenAccount: buyerTokenAddress, 60 | buyerAuthority: buyer.publicKey, 61 | }) 62 | .signers([buyer]) 63 | .rpc(); 64 | }); 65 | }); -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/tests/test-sell.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | // ** Comment this to use solpg imported IDL ** 3 | import { 4 | createKeypairFromFile, 5 | } from './util'; 6 | import { MintNft } from "../target/types/mint_nft"; 7 | 8 | 9 | describe("sell-nft", async () => { 10 | 11 | 12 | const provider = anchor.AnchorProvider.env() 13 | const wallet = provider.wallet as anchor.Wallet; 14 | anchor.setProvider(provider); 15 | 16 | // ** Un-comment this to use solpg imported IDL ** 17 | // const program = new anchor.Program( 18 | // require("../solpg/idl.json"), 19 | // new anchor.web3.PublicKey("H2UJjAQTuVJYhaBhh6GD2KaprLBTp1vhP2aaHioya5NM"), 20 | // ); 21 | // ** Comment this to use solpg imported IDL ** 22 | const program = anchor.workspace.MintNft as anchor.Program; 23 | 24 | 25 | it("Sell!", async () => { 26 | 27 | // Testing constants 28 | 29 | const saleAmount = 1 * anchor.web3.LAMPORTS_PER_SOL; 30 | const mint: anchor.web3.PublicKey = new anchor.web3.PublicKey( 31 | "59UQbpn69GKiTZajEy6y732AFYB3HGY7q1ymdj2qomS2" 32 | ); 33 | const buyer: anchor.web3.Keypair = await createKeypairFromFile(__dirname + "/keypairs/buyer1.json"); 34 | console.log(`Buyer public key: ${buyer.publicKey}`); 35 | 36 | // Derive the associated token account address for owner & buyer 37 | 38 | const ownerTokenAddress = await anchor.utils.token.associatedAddress({ 39 | mint: mint, 40 | owner: wallet.publicKey 41 | }); 42 | const buyerTokenAddress = await anchor.utils.token.associatedAddress({ 43 | mint: mint, 44 | owner: buyer.publicKey, 45 | }); 46 | console.log(`Request to sell NFT: ${mint} for ${saleAmount} lamports.`); 47 | console.log(`Owner's Token Address: ${ownerTokenAddress}`); 48 | console.log(`Buyer's Token Address: ${buyerTokenAddress}`); 49 | 50 | // Transact with the "sell" function in our on-chain program 51 | 52 | await program.methods.sell( 53 | new anchor.BN(saleAmount) 54 | ) 55 | .accounts({ 56 | mint: mint, 57 | ownerTokenAccount: ownerTokenAddress, 58 | ownerAuthority: wallet.publicKey, 59 | buyerTokenAccount: buyerTokenAddress, 60 | buyerAuthority: buyer.publicKey, 61 | }) 62 | .signers([buyer]) 63 | .rpc(); 64 | }); 65 | }); -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/tests/test-mint.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import { NftCollection } from "../target/types/nft_collection"; 3 | 4 | 5 | describe("nft-marketplace", async () => { 6 | 7 | const testNftTitle = "Beta"; 8 | const testNftSymbol = "BETA"; 9 | const testNftUri = "https://raw.githubusercontent.com/Coding-and-Crypto/Solana-NFT-Marketplace/master/assets/example.json"; 10 | 11 | const provider = anchor.AnchorProvider.env() 12 | const wallet = provider.wallet as anchor.Wallet; 13 | anchor.setProvider(provider); 14 | 15 | const program = anchor.workspace.NftCollection as anchor.Program; 16 | 17 | const TOKEN_METADATA_PROGRAM_ID = new anchor.web3.PublicKey( 18 | "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" 19 | ); 20 | 21 | 22 | it("Mint!", async () => { 23 | 24 | // Derive the mint address and the associated token account address 25 | 26 | const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); 27 | const tokenAddress = await anchor.utils.token.associatedAddress({ 28 | mint: mintKeypair.publicKey, 29 | owner: wallet.publicKey 30 | }); 31 | console.log(`New token: ${mintKeypair.publicKey}`); 32 | 33 | // Derive the metadata and master edition addresses 34 | 35 | const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( 36 | [ 37 | Buffer.from("metadata"), 38 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 39 | mintKeypair.publicKey.toBuffer(), 40 | ], 41 | TOKEN_METADATA_PROGRAM_ID 42 | ))[0]; 43 | console.log("Metadata initialized"); 44 | const masterEditionAddress = (await anchor.web3.PublicKey.findProgramAddress( 45 | [ 46 | Buffer.from("metadata"), 47 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 48 | mintKeypair.publicKey.toBuffer(), 49 | Buffer.from("edition"), 50 | ], 51 | TOKEN_METADATA_PROGRAM_ID 52 | ))[0]; 53 | console.log("Master edition metadata initialized"); 54 | 55 | // Transact with the "mint" function in our on-chain program 56 | 57 | await program.methods.mint( 58 | testNftTitle, testNftSymbol, testNftUri 59 | ) 60 | .accounts({ 61 | masterEdition: masterEditionAddress, 62 | metadata: metadataAddress, 63 | mint: mintKeypair.publicKey, 64 | tokenAccount: tokenAddress, 65 | mintAuthority: wallet.publicKey, 66 | tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, 67 | }) 68 | .signers([mintKeypair]) 69 | .rpc(); 70 | }); 71 | }); -------------------------------------------------------------------------------- /nfts/nft-collection/app/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nfts/mint-nft/tests/mint-nft.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | // ** Comment this to use solpg imported IDL ** 3 | import { MintNft } from "../target/types/mint_nft"; 4 | 5 | 6 | describe("nft-marketplace", async () => { 7 | 8 | const testNftTitle = "Beta"; 9 | const testNftSymbol = "BETA"; 10 | const testNftUri = "https://raw.githubusercontent.com/Coding-and-Crypto/Solana-NFT-Marketplace/master/assets/example.json"; 11 | 12 | const provider = anchor.AnchorProvider.env() 13 | const wallet = provider.wallet as anchor.Wallet; 14 | anchor.setProvider(provider); 15 | 16 | // ** Un-comment this to use solpg imported IDL ** 17 | // const program = new anchor.Program( 18 | // require("../solpg/idl.json"), 19 | // new anchor.web3.PublicKey("H2UJjAQTuVJYhaBhh6GD2KaprLBTp1vhP2aaHioya5NM"), 20 | // ); 21 | // ** Comment this to use solpg imported IDL ** 22 | const program = anchor.workspace.MintNft as anchor.Program; 23 | 24 | const TOKEN_METADATA_PROGRAM_ID = new anchor.web3.PublicKey( 25 | "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" 26 | ); 27 | 28 | 29 | it("Mint!", async () => { 30 | 31 | // Derive the mint address and the associated token account address 32 | 33 | const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); 34 | const tokenAddress = await anchor.utils.token.associatedAddress({ 35 | mint: mintKeypair.publicKey, 36 | owner: wallet.publicKey 37 | }); 38 | console.log(`New token: ${mintKeypair.publicKey}`); 39 | 40 | // Derive the metadata and master edition addresses 41 | 42 | const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( 43 | [ 44 | Buffer.from("metadata"), 45 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 46 | mintKeypair.publicKey.toBuffer(), 47 | ], 48 | TOKEN_METADATA_PROGRAM_ID 49 | ))[0]; 50 | console.log("Metadata initialized"); 51 | const masterEditionAddress = (await anchor.web3.PublicKey.findProgramAddress( 52 | [ 53 | Buffer.from("metadata"), 54 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 55 | mintKeypair.publicKey.toBuffer(), 56 | Buffer.from("edition"), 57 | ], 58 | TOKEN_METADATA_PROGRAM_ID 59 | ))[0]; 60 | console.log("Master edition metadata initialized"); 61 | 62 | // Transact with the "mint" function in our on-chain program 63 | 64 | await program.methods.mint( 65 | testNftTitle, testNftSymbol, testNftUri 66 | ) 67 | .accounts({ 68 | masterEdition: masterEditionAddress, 69 | metadata: metadataAddress, 70 | mint: mintKeypair.publicKey, 71 | tokenAccount: tokenAddress, 72 | mintAuthority: wallet.publicKey, 73 | tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, 74 | }) 75 | .signers([mintKeypair]) 76 | .rpc(); 77 | }); 78 | }); -------------------------------------------------------------------------------- /nfts/sell-nft/tests/test-mint.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | // ** Comment this to use solpg imported IDL ** 3 | import { MintNft } from "../target/types/mint_nft"; 4 | 5 | 6 | describe("nft-marketplace", async () => { 7 | 8 | const testNftTitle = "Beta"; 9 | const testNftSymbol = "BETA"; 10 | const testNftUri = "https://raw.githubusercontent.com/Coding-and-Crypto/Solana-NFT-Marketplace/master/assets/example.json"; 11 | 12 | const provider = anchor.AnchorProvider.env() 13 | const wallet = provider.wallet as anchor.Wallet; 14 | anchor.setProvider(provider); 15 | 16 | // ** Un-comment this to use solpg imported IDL ** 17 | // const program = new anchor.Program( 18 | // require("../solpg/idl.json"), 19 | // new anchor.web3.PublicKey("H2UJjAQTuVJYhaBhh6GD2KaprLBTp1vhP2aaHioya5NM"), 20 | // ); 21 | // ** Comment this to use solpg imported IDL ** 22 | const program = anchor.workspace.MintNft as anchor.Program; 23 | 24 | const TOKEN_METADATA_PROGRAM_ID = new anchor.web3.PublicKey( 25 | "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" 26 | ); 27 | 28 | 29 | it("Mint!", async () => { 30 | 31 | // Derive the mint address and the associated token account address 32 | 33 | const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); 34 | const tokenAddress = await anchor.utils.token.associatedAddress({ 35 | mint: mintKeypair.publicKey, 36 | owner: wallet.publicKey 37 | }); 38 | console.log(`New token: ${mintKeypair.publicKey}`); 39 | 40 | // Derive the metadata and master edition addresses 41 | 42 | const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( 43 | [ 44 | Buffer.from("metadata"), 45 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 46 | mintKeypair.publicKey.toBuffer(), 47 | ], 48 | TOKEN_METADATA_PROGRAM_ID 49 | ))[0]; 50 | console.log("Metadata initialized"); 51 | const masterEditionAddress = (await anchor.web3.PublicKey.findProgramAddress( 52 | [ 53 | Buffer.from("metadata"), 54 | TOKEN_METADATA_PROGRAM_ID.toBuffer(), 55 | mintKeypair.publicKey.toBuffer(), 56 | Buffer.from("edition"), 57 | ], 58 | TOKEN_METADATA_PROGRAM_ID 59 | ))[0]; 60 | console.log("Master edition metadata initialized"); 61 | 62 | // Transact with the "mint" function in our on-chain program 63 | 64 | await program.methods.mint( 65 | testNftTitle, testNftSymbol, testNftUri 66 | ) 67 | .accounts({ 68 | masterEdition: masterEditionAddress, 69 | metadata: metadataAddress, 70 | mint: mintKeypair.publicKey, 71 | tokenAccount: tokenAddress, 72 | mintAuthority: wallet.publicKey, 73 | tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, 74 | }) 75 | .signers([mintKeypair]) 76 | .rpc(); 77 | }); 78 | }); -------------------------------------------------------------------------------- /nfts/sell-nft/programs/mint-nft/src/sell.rs: -------------------------------------------------------------------------------- 1 | use { 2 | anchor_lang::{ 3 | prelude::*, 4 | system_program, 5 | }, 6 | anchor_spl::{ 7 | associated_token, 8 | token, 9 | }, 10 | }; 11 | 12 | 13 | pub fn sell( 14 | ctx: Context, 15 | sale_lamports: u64 16 | ) -> Result<()> { 17 | 18 | msg!("Initiating transfer of {} lamports...", sale_lamports); 19 | msg!("Purchaser (sending lamports): {}", &ctx.accounts.buyer_authority.key()); 20 | msg!("Seller (receiving lamports): {}", &ctx.accounts.owner_authority.key()); 21 | system_program::transfer( 22 | CpiContext::new( 23 | ctx.accounts.system_program.to_account_info(), 24 | system_program::Transfer { 25 | from: ctx.accounts.buyer_authority.to_account_info(), 26 | to: ctx.accounts.owner_authority.to_account_info(), 27 | } 28 | ), 29 | sale_lamports 30 | )?; 31 | 32 | msg!("Lamports transferred successfully."); 33 | 34 | msg!("Creating buyer token account..."); 35 | msg!("Buyer Token Address: {}", &ctx.accounts.buyer_token_account.key()); 36 | associated_token::create( 37 | CpiContext::new( 38 | ctx.accounts.associated_token_program.to_account_info(), 39 | associated_token::Create { 40 | payer: ctx.accounts.buyer_authority.to_account_info(), 41 | associated_token: ctx.accounts.buyer_token_account.to_account_info(), 42 | authority: ctx.accounts.buyer_authority.to_account_info(), 43 | mint: ctx.accounts.mint.to_account_info(), 44 | system_program: ctx.accounts.system_program.to_account_info(), 45 | token_program: ctx.accounts.token_program.to_account_info(), 46 | rent: ctx.accounts.rent.to_account_info(), 47 | }, 48 | ), 49 | )?; 50 | 51 | msg!("Transferring NFT..."); 52 | msg!("Owner Token Address: {}", &ctx.accounts.owner_token_account.key()); 53 | msg!("Buyer Token Address: {}", &ctx.accounts.buyer_token_account.key()); 54 | token::transfer( 55 | CpiContext::new( 56 | ctx.accounts.token_program.to_account_info(), 57 | token::Transfer { 58 | from: ctx.accounts.owner_token_account.to_account_info(), 59 | to: ctx.accounts.buyer_token_account.to_account_info(), 60 | authority: ctx.accounts.owner_authority.to_account_info(), 61 | } 62 | ), 63 | 1 64 | )?; 65 | msg!("NFT transferred successfully."); 66 | 67 | msg!("Sale completed successfully!"); 68 | 69 | Ok(()) 70 | } 71 | 72 | 73 | #[derive(Accounts)] 74 | pub struct SellNft<'info> { 75 | #[account(mut)] 76 | pub mint: Account<'info, token::Mint>, 77 | #[account(mut)] 78 | pub owner_token_account: Account<'info, token::TokenAccount>, 79 | #[account(mut)] 80 | pub owner_authority: Signer<'info>, 81 | /// CHECK: We're about to create this with Anchor 82 | #[account(mut)] 83 | pub buyer_token_account: UncheckedAccount<'info>, 84 | #[account(mut)] 85 | pub buyer_authority: Signer<'info>, 86 | pub rent: Sysvar<'info, Rent>, 87 | pub system_program: Program<'info, System>, 88 | pub token_program: Program<'info, token::Token>, 89 | pub associated_token_program: Program<'info, associated_token::AssociatedToken>, 90 | } -------------------------------------------------------------------------------- /pdas/tests/pdas.ts: -------------------------------------------------------------------------------- 1 | import * as anchor from "@project-serum/anchor"; 2 | import { Pdas } from "../target/types/pdas"; 3 | 4 | 5 | 6 | function shortKey(key: anchor.web3.PublicKey) { 7 | return key.toString().substring(0, 8); 8 | } 9 | 10 | 11 | describe("pdas", () => { 12 | 13 | const provider = anchor.AnchorProvider.env(); 14 | anchor.setProvider(provider); 15 | const program = anchor.workspace.Pdas as anchor.Program; 16 | 17 | async function generateKeypair() { 18 | let keypair = anchor.web3.Keypair.generate(); 19 | await provider.connection.requestAirdrop( 20 | keypair.publicKey, 21 | 2 * anchor.web3.LAMPORTS_PER_SOL 22 | ); 23 | await new Promise( resolve => setTimeout(resolve, 3 * 1000) ); // Sleep 3s 24 | return keypair; 25 | } 26 | 27 | async function derivePda(color: string, pubkey: anchor.web3.PublicKey) { 28 | let [pda, _] = await anchor.web3.PublicKey.findProgramAddress( 29 | [ 30 | pubkey.toBuffer(), 31 | Buffer.from("_"), 32 | Buffer.from(color), 33 | ], 34 | program.programId 35 | ); 36 | return pda; 37 | } 38 | 39 | async function createLedgerAccount( 40 | color: string, 41 | pda: anchor.web3.PublicKey, 42 | wallet: anchor.web3.Keypair 43 | ) { 44 | await program.methods.createLedger(color) 45 | .accounts({ 46 | ledgerAccount: pda, 47 | wallet: wallet.publicKey, 48 | }) 49 | .signers([wallet]) 50 | .rpc(); 51 | } 52 | 53 | async function modifyLedger( 54 | color: string, 55 | newBalance: number, 56 | wallet: anchor.web3.Keypair, 57 | ) { 58 | 59 | console.log("--------------------------------------------------"); 60 | let data; 61 | let pda = await derivePda(color, wallet.publicKey); 62 | 63 | console.log(`Checking if account ${shortKey(pda)} exists for color: ${color}...`); 64 | try { 65 | 66 | data = await program.account.ledger.fetch(pda); 67 | console.log("It does."); 68 | 69 | } catch (e) { 70 | 71 | console.log("It does NOT. Creating..."); 72 | await createLedgerAccount(color, pda, wallet); 73 | data = await program.account.ledger.fetch(pda); 74 | }; 75 | 76 | console.log("Success."); 77 | console.log("Data:") 78 | console.log(` Color: ${data.color} Balance: ${data.balance}`); 79 | console.log(`Modifying balance of ${data.color} from ${data.balance} to ${newBalance}`); 80 | 81 | await program.methods.modifyLedger(newBalance) 82 | .accounts({ 83 | ledgerAccount: pda, 84 | wallet: wallet.publicKey, 85 | }) 86 | .signers([wallet]) 87 | .rpc(); 88 | 89 | data = await program.account.ledger.fetch(pda); 90 | console.log("New Data:") 91 | console.log(` Color: ${data.color} Balance: ${data.balance}`); 92 | console.log("Success."); 93 | } 94 | 95 | 96 | it("An example of PDAs in action", async () => { 97 | 98 | const testKeypair1 = await generateKeypair(); 99 | await modifyLedger("red", 2, testKeypair1); 100 | await modifyLedger("red", 4, testKeypair1); 101 | await modifyLedger("blue", 2, testKeypair1); 102 | 103 | const testKeypair2 = await generateKeypair(); 104 | await modifyLedger("red", 3, testKeypair2); 105 | await modifyLedger("green", 3, testKeypair2); 106 | }); 107 | }); 108 | -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/programs/nft-collection/src/sell.rs: -------------------------------------------------------------------------------- 1 | use { 2 | anchor_lang::{ 3 | prelude::*, 4 | system_program, 5 | }, 6 | anchor_spl::{ 7 | associated_token, 8 | token, 9 | }, 10 | }; 11 | 12 | 13 | pub fn sell( 14 | ctx: Context, 15 | sale_lamports: u64 16 | ) -> Result<()> { 17 | 18 | msg!("Initiating transfer of {} lamports...", sale_lamports); 19 | msg!("Purchaser (sending lamports): {}", &ctx.accounts.buyer_authority.key()); 20 | msg!("Seller (receiving lamports): {}", &ctx.accounts.owner_authority.key()); 21 | system_program::transfer( 22 | CpiContext::new( 23 | ctx.accounts.system_program.to_account_info(), 24 | system_program::Transfer { 25 | from: ctx.accounts.buyer_authority.to_account_info(), 26 | to: ctx.accounts.owner_authority.to_account_info(), 27 | } 28 | ), 29 | sale_lamports 30 | )?; 31 | 32 | msg!("Lamports transferred successfully."); 33 | 34 | msg!("Creating buyer token account..."); 35 | msg!("Buyer Token Address: {}", &ctx.accounts.buyer_token_account.key()); 36 | associated_token::create( 37 | CpiContext::new( 38 | ctx.accounts.associated_token_program.to_account_info(), 39 | associated_token::Create { 40 | payer: ctx.accounts.buyer_authority.to_account_info(), 41 | associated_token: ctx.accounts.buyer_token_account.to_account_info(), 42 | authority: ctx.accounts.buyer_authority.to_account_info(), 43 | mint: ctx.accounts.mint.to_account_info(), 44 | system_program: ctx.accounts.system_program.to_account_info(), 45 | token_program: ctx.accounts.token_program.to_account_info(), 46 | rent: ctx.accounts.rent.to_account_info(), 47 | }, 48 | ), 49 | )?; 50 | 51 | msg!("Transferring NFT..."); 52 | msg!("Owner Token Address: {}", &ctx.accounts.owner_token_account.key()); 53 | msg!("Buyer Token Address: {}", &ctx.accounts.buyer_token_account.key()); 54 | token::transfer( 55 | CpiContext::new( 56 | ctx.accounts.token_program.to_account_info(), 57 | token::Transfer { 58 | from: ctx.accounts.owner_token_account.to_account_info(), 59 | to: ctx.accounts.buyer_token_account.to_account_info(), 60 | authority: ctx.accounts.owner_authority.to_account_info(), 61 | } 62 | ), 63 | 1 64 | )?; 65 | msg!("NFT transferred successfully."); 66 | 67 | msg!("Sale completed successfully!"); 68 | 69 | Ok(()) 70 | } 71 | 72 | 73 | #[derive(Accounts)] 74 | pub struct SellNft<'info> { 75 | #[account(mut)] 76 | pub mint: Account<'info, token::Mint>, 77 | #[account(mut)] 78 | pub owner_token_account: Account<'info, token::TokenAccount>, 79 | #[account(mut)] 80 | pub owner_authority: Signer<'info>, 81 | /// CHECK: We're about to create this with Anchor 82 | #[account(mut)] 83 | pub buyer_token_account: UncheckedAccount<'info>, 84 | #[account(mut)] 85 | pub buyer_authority: Signer<'info>, 86 | pub rent: Sysvar<'info, Rent>, 87 | pub system_program: Program<'info, System>, 88 | pub token_program: Program<'info, token::Token>, 89 | pub associated_token_program: Program<'info, associated_token::AssociatedToken>, 90 | } -------------------------------------------------------------------------------- /nfts/mint-nft-raw/mint/src/lib.rs: -------------------------------------------------------------------------------- 1 | use { 2 | solana_program::{ 3 | account_info::{next_account_info, AccountInfo}, 4 | entrypoint, 5 | entrypoint::ProgramResult, 6 | msg, 7 | native_token::LAMPORTS_PER_SOL, 8 | program::invoke, 9 | pubkey::Pubkey, 10 | system_instruction, 11 | }, 12 | spl_token::{ 13 | instruction as token_instruction, 14 | }, 15 | spl_associated_token_account::{ 16 | instruction as token_account_instruction, 17 | }, 18 | }; 19 | 20 | 21 | entrypoint!(process_instruction); 22 | 23 | 24 | fn process_instruction( 25 | _program_id: &Pubkey, 26 | accounts: &[AccountInfo], 27 | _instruction_data: &[u8], 28 | ) -> ProgramResult { 29 | 30 | let accounts_iter = &mut accounts.iter(); 31 | 32 | let mint = next_account_info(accounts_iter)?; 33 | let token_account = next_account_info(accounts_iter)?; 34 | let mint_authority = next_account_info(accounts_iter)?; 35 | let rent = next_account_info(accounts_iter)?; 36 | let system_program = next_account_info(accounts_iter)?; 37 | let token_program = next_account_info(accounts_iter)?; 38 | let associated_token_program = next_account_info(accounts_iter)?; 39 | 40 | msg!("Creating mint account..."); 41 | msg!("Mint: {}", mint.key); 42 | invoke( 43 | &system_instruction::create_account( 44 | &mint_authority.key, 45 | &mint.key, 46 | LAMPORTS_PER_SOL, 47 | 82, 48 | &token_program.key, 49 | ), 50 | &[ 51 | mint.clone(), 52 | mint_authority.clone(), 53 | token_program.clone(), 54 | ] 55 | )?; 56 | 57 | msg!("Initializing mint account..."); 58 | msg!("Mint: {}", mint.key); 59 | invoke( 60 | &token_instruction::initialize_mint( 61 | &token_program.key, 62 | &mint.key, 63 | &mint_authority.key, 64 | Some(&mint_authority.key), 65 | 0, 66 | )?, 67 | &[ 68 | mint.clone(), 69 | mint_authority.clone(), 70 | token_program.clone(), 71 | rent.clone(), 72 | ] 73 | )?; 74 | 75 | msg!("Creating token account..."); 76 | msg!("Token Address: {}", token_account.key); 77 | invoke( 78 | &token_account_instruction::create_associated_token_account( 79 | &mint_authority.key, 80 | &mint_authority.key, 81 | &mint.key, 82 | ), 83 | &[ 84 | mint.clone(), 85 | token_account.clone(), 86 | mint_authority.clone(), 87 | token_program.clone(), 88 | associated_token_program.clone(), 89 | ] 90 | )?; 91 | 92 | msg!("Minting token to token account..."); 93 | msg!("Mint: {}", mint.key); 94 | msg!("Token Address: {}", token_account.key); 95 | invoke( 96 | &token_instruction::mint_to( 97 | &token_program.key, 98 | &mint.key, 99 | &token_account.key, 100 | &mint_authority.key, 101 | &[&mint_authority.key], 102 | 1, 103 | )?, 104 | &[ 105 | mint.clone(), 106 | mint_authority.clone(), 107 | token_account.clone(), 108 | token_program.clone(), 109 | rent.clone(), 110 | ] 111 | )?; 112 | 113 | msg!("Token mint process completed successfully."); 114 | 115 | Ok(()) 116 | } 117 | -------------------------------------------------------------------------------- /nfts/mint-nft-raw/app.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ASSOCIATED_TOKEN_PROGRAM_ID, 3 | getAssociatedTokenAddress, 4 | TOKEN_PROGRAM_ID, 5 | } from '@solana/spl-token'; 6 | import { 7 | Connection, 8 | Keypair, 9 | PublicKey, 10 | SystemProgram, 11 | SYSVAR_RENT_PUBKEY, 12 | TransactionInstruction, 13 | Transaction, 14 | sendAndConfirmTransaction, 15 | } from '@solana/web3.js'; 16 | import { 17 | createKeypairFromFile, 18 | } from './util'; 19 | import fs from 'mz/fs'; 20 | import os from 'os'; 21 | import path from 'path'; 22 | import yaml from 'yaml'; 23 | 24 | 25 | // Path to local Solana CLI config file. 26 | const CONFIG_FILE_PATH = path.resolve( 27 | os.homedir(), 28 | '.config', 29 | 'solana', 30 | 'cli', 31 | 'config.yml', 32 | ); 33 | 34 | 35 | export async function main() { 36 | 37 | const connection = new Connection('https://api.devnet.solana.com', 'confirmed'); 38 | console.log(`Successfully connected to Solana dev net.`); 39 | 40 | const configYml = await fs.readFile(CONFIG_FILE_PATH, {encoding: 'utf8'}); 41 | const keypairPath = await yaml.parse(configYml).keypair_path; 42 | const wallet = await createKeypairFromFile(keypairPath); 43 | console.log(`Local account loaded successfully.`); 44 | 45 | const programKeypair = await createKeypairFromFile( 46 | path.join( 47 | path.resolve(__dirname, './dist/program'), 48 | 'mint-keypair.json' 49 | )); 50 | const programId = programKeypair.publicKey; 51 | console.log(`Program ID: ${programId.toBase58()}`); 52 | 53 | // Derive the mint address and the associated token account address 54 | 55 | const mintKeypair: Keypair = Keypair.generate(); 56 | const tokenAddress = await getAssociatedTokenAddress( 57 | mintKeypair.publicKey, 58 | wallet.publicKey 59 | ); 60 | console.log(`New token: ${mintKeypair.publicKey}`); 61 | 62 | // Transact with our program 63 | 64 | const instruction = new TransactionInstruction({ 65 | keys: [ 66 | // Mint account 67 | { 68 | pubkey: mintKeypair.publicKey, 69 | isSigner: true, 70 | isWritable: true, 71 | }, 72 | // Token account 73 | { 74 | pubkey: tokenAddress, 75 | isSigner: false, 76 | isWritable: true, 77 | }, 78 | // Mint Authority 79 | { 80 | pubkey: wallet.publicKey, 81 | isSigner: true, 82 | isWritable: false, 83 | }, 84 | // Rent account 85 | { 86 | pubkey: SYSVAR_RENT_PUBKEY, 87 | isSigner: false, 88 | isWritable: false, 89 | }, 90 | // System program 91 | { 92 | pubkey: SystemProgram.programId, 93 | isSigner: false, 94 | isWritable: false, 95 | }, 96 | // Token program 97 | { 98 | pubkey: TOKEN_PROGRAM_ID, 99 | isSigner: false, 100 | isWritable: false, 101 | }, 102 | // Associated token program 103 | { 104 | pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, 105 | isSigner: false, 106 | isWritable: false, 107 | }, 108 | ], 109 | programId: programId, 110 | data: Buffer.alloc(0), 111 | }) 112 | await sendAndConfirmTransaction( 113 | connection, 114 | new Transaction().add(instruction), 115 | [wallet, mintKeypair], 116 | ) 117 | } 118 | 119 | main().then( 120 | () => process.exit(), 121 | err => { 122 | console.error(err); 123 | process.exit(-1); 124 | }, 125 | ); -------------------------------------------------------------------------------- /transfer-sol/client/main.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Connection, 3 | Keypair, 4 | LAMPORTS_PER_SOL, 5 | PublicKey, 6 | sendAndConfirmTransaction, 7 | SystemProgram, 8 | Transaction, 9 | TransactionInstruction, 10 | } from '@solana/web3.js'; 11 | import {readFileSync} from "fs"; 12 | import path from 'path'; 13 | 14 | const lo = require("buffer-layout"); 15 | // const BN = require("bn.js"); 16 | 17 | 18 | 19 | /** 20 | * Vars 21 | */ 22 | 23 | const SOLANA_NETWORK = "devnet"; 24 | 25 | let connection: Connection; 26 | let programKeypair: Keypair; 27 | let programId: PublicKey; 28 | 29 | let ringoKeypair: Keypair; 30 | let georgeKeypair: Keypair; 31 | let paulKeypair: Keypair; 32 | let johnKeypair: Keypair; 33 | 34 | 35 | 36 | /** 37 | * Helper functions. 38 | */ 39 | 40 | function createKeypairFromFile(path: string): Keypair { 41 | return Keypair.fromSecretKey( 42 | Buffer.from(JSON.parse(readFileSync(path, "utf-8"))) 43 | ) 44 | } 45 | 46 | 47 | /** 48 | * Here we are sending lamports using the Rust program we wrote. 49 | * So this looks familiar. We're just hitting our program with the proper instructions. 50 | */ 51 | async function sendLamports(from: Keypair, to: PublicKey, amount: number) { 52 | 53 | let data = Buffer.alloc(8) // 8 bytes 54 | // lo.ns64("value").encode(new BN(amount), data); 55 | lo.ns64("value").encode(amount, data); 56 | 57 | let ins = new TransactionInstruction({ 58 | keys: [ 59 | {pubkey: from.publicKey, isSigner: true, isWritable: true}, 60 | {pubkey: to, isSigner: false, isWritable: true}, 61 | {pubkey: SystemProgram.programId, isSigner: false, isWritable: false}, 62 | ], 63 | programId: programId, 64 | data: data, 65 | }) 66 | 67 | await sendAndConfirmTransaction( 68 | connection, 69 | new Transaction().add(ins), 70 | [from] 71 | ); 72 | } 73 | 74 | 75 | 76 | /** 77 | * Main 78 | */ 79 | 80 | async function main() { 81 | 82 | connection = new Connection( 83 | `https://api.${SOLANA_NETWORK}.solana.com`, 'confirmed' 84 | ); 85 | 86 | programKeypair = createKeypairFromFile( 87 | path.join( 88 | path.resolve(__dirname, '../_dist/program'), 89 | 'program-keypair.json' 90 | ) 91 | ); 92 | programId = programKeypair.publicKey; 93 | 94 | // Our sample members are Ringo, George, Paul & John. 95 | ringoKeypair = createKeypairFromFile(__dirname + "/../accounts/ringo.json"); 96 | georgeKeypair = createKeypairFromFile(__dirname + "/../accounts/george.json"); 97 | paulKeypair = createKeypairFromFile(__dirname + "/../accounts/paul.json"); 98 | johnKeypair = createKeypairFromFile(__dirname + "/../accounts/john.json"); 99 | 100 | // We'll start by airdropping some lamports to Paul & John. 101 | // await connection.confirmTransaction( 102 | // await connection.requestAirdrop( 103 | // paulKeypair.publicKey, 104 | // LAMPORTS_PER_SOL, 105 | // ) 106 | // ); 107 | // await connection.confirmTransaction( 108 | // await connection.requestAirdrop( 109 | // johnKeypair.publicKey, 110 | // LAMPORTS_PER_SOL, 111 | // ) 112 | // ); 113 | 114 | // John sends some SOL to Ringo. 115 | console.log("John sends some SOL to Ringo..."); 116 | console.log(` John's public key: ${johnKeypair.publicKey}`); 117 | console.log(` Ringo's public key: ${ringoKeypair.publicKey}`); 118 | await sendLamports(johnKeypair, ringoKeypair.publicKey, 5000000); 119 | 120 | // Paul sends some SOL to George. 121 | console.log("Paul sends some SOL to George..."); 122 | console.log(` Paul's public key: ${paulKeypair.publicKey}`); 123 | console.log(` George's public key: ${georgeKeypair.publicKey}`); 124 | await sendLamports(paulKeypair, georgeKeypair.publicKey, 4000000); 125 | 126 | // George sends some SOL over to John. 127 | console.log("George sends some SOL over to John..."); 128 | console.log(` George's public key: ${georgeKeypair.publicKey}`); 129 | console.log(` John's public key: ${johnKeypair.publicKey}`); 130 | await sendLamports(georgeKeypair, johnKeypair.publicKey, 2000000); 131 | } 132 | 133 | 134 | main().then( 135 | () => process.exit(), 136 | err => { 137 | console.error(err); 138 | process.exit(-1); 139 | }, 140 | ); -------------------------------------------------------------------------------- /math-stuff/src/client/math.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | Connection, 4 | PublicKey, 5 | LAMPORTS_PER_SOL, 6 | SystemProgram, 7 | TransactionInstruction, 8 | Transaction, 9 | sendAndConfirmTransaction, 10 | } from '@solana/web3.js'; 11 | import { 12 | createKeypairFromFile, 13 | } from './util'; 14 | import fs from 'mz/fs'; 15 | import os from 'os'; 16 | import path from 'path'; 17 | import yaml from 'yaml'; 18 | 19 | 20 | 21 | /* 22 | Path to Solana CLI config file. 23 | */ 24 | const CONFIG_FILE_PATH = path.resolve( 25 | os.homedir(), 26 | '.config', 27 | 'solana', 28 | 'cli', 29 | 'config.yml', 30 | ); 31 | 32 | 33 | let connection: Connection; 34 | let localKeypair: Keypair; 35 | let programKeypair: Keypair; 36 | let programId: PublicKey; 37 | let clientPubKey: PublicKey; 38 | 39 | 40 | const PROGRAM_PATH = path.resolve(__dirname, '../../dist/program'); 41 | 42 | 43 | /* 44 | Connect to dev net. 45 | */ 46 | export async function connect() { 47 | connection = new Connection('https://api.devnet.solana.com', 'confirmed'); 48 | 49 | console.log(`Successfully connected to Solana dev net.`); 50 | } 51 | 52 | 53 | /* 54 | Use local keypair for client. 55 | */ 56 | export async function getLocalAccount() { 57 | const configYml = await fs.readFile(CONFIG_FILE_PATH, {encoding: 'utf8'}); 58 | const keypairPath = await yaml.parse(configYml).keypair_path; 59 | localKeypair = await createKeypairFromFile(keypairPath); 60 | // const airdropRequest = await connection.requestAirdrop( 61 | // localKeypair.publicKey, 62 | // LAMPORTS_PER_SOL*2, 63 | // ); 64 | // await connection.confirmTransaction(airdropRequest); 65 | 66 | console.log(`Local account loaded successfully.`); 67 | console.log(`Local account's address is:`); 68 | console.log(` ${localKeypair.publicKey}`); 69 | } 70 | 71 | 72 | /* 73 | Get the targeted program. 74 | */ 75 | export async function getProgram(programName: string) { 76 | programKeypair = await createKeypairFromFile( 77 | path.join(PROGRAM_PATH, programName + '-keypair.json') 78 | ); 79 | programId = programKeypair.publicKey; 80 | 81 | console.log(`We're going to ping the ${programName} program.`); 82 | console.log(`It's Program ID is:`); 83 | console.log(` ${programId.toBase58()}`) 84 | } 85 | 86 | 87 | /* 88 | Configure client account. 89 | */ 90 | export async function configureClientAccount(accountSpaceSize: number) { 91 | const SEED = 'test1'; 92 | clientPubKey = await PublicKey.createWithSeed( 93 | localKeypair.publicKey, 94 | SEED, 95 | programId, 96 | ); 97 | 98 | console.log(`For simplicity's sake, we've created an address using a seed.`); 99 | console.log(`That seed is just the string "test(num)".`); 100 | console.log(`The generated address is:`); 101 | console.log(` ${clientPubKey.toBase58()}`); 102 | 103 | // Make sure it doesn't exist already. 104 | const clientAccount = await connection.getAccountInfo(clientPubKey); 105 | if (clientAccount === null) { 106 | 107 | console.log(`Looks like that account does not exist. Let's create it.`); 108 | 109 | const transaction = new Transaction().add( 110 | SystemProgram.createAccountWithSeed({ 111 | fromPubkey: localKeypair.publicKey, 112 | basePubkey: localKeypair.publicKey, 113 | seed: SEED, 114 | newAccountPubkey: clientPubKey, 115 | lamports: LAMPORTS_PER_SOL, 116 | space: accountSpaceSize, 117 | programId, 118 | }), 119 | ); 120 | await sendAndConfirmTransaction(connection, transaction, [localKeypair]); 121 | 122 | console.log(`Client account created successfully.`); 123 | } else { 124 | console.log(`Looks like that account exists already. We can just use it.`); 125 | } 126 | } 127 | 128 | 129 | /* 130 | Ping the program. 131 | */ 132 | export async function pingProgram(programName: string) { 133 | console.log(`All right, let's run it.`); 134 | console.log(`Pinging ${programName} program...`); 135 | 136 | const instruction = new TransactionInstruction({ 137 | keys: [{pubkey: clientPubKey, isSigner: false, isWritable: true}], 138 | programId, 139 | data: Buffer.alloc(0), // Empty instruction data 140 | }); 141 | await sendAndConfirmTransaction( 142 | connection, 143 | new Transaction().add(instruction), 144 | [localKeypair], 145 | ); 146 | 147 | console.log(`Ping successful.`); 148 | } 149 | 150 | 151 | /* 152 | Run the example (main). 153 | */ 154 | export async function example(programName: string, accountSpaceSize: number) { 155 | await connect(); 156 | await getLocalAccount(); 157 | await getProgram(programName); 158 | await configureClientAccount(accountSpaceSize); 159 | await pingProgram(programName); 160 | } -------------------------------------------------------------------------------- /advanced-math/src/client/math.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Keypair, 3 | Connection, 4 | PublicKey, 5 | LAMPORTS_PER_SOL, 6 | SystemProgram, 7 | TransactionInstruction, 8 | Transaction, 9 | sendAndConfirmTransaction, 10 | } from '@solana/web3.js'; 11 | import { 12 | createKeypairFromFile, 13 | getStringForInstruction, 14 | createCalculatorInstructions, 15 | } from './util'; 16 | import fs from 'mz/fs'; 17 | import os from 'os'; 18 | import path from 'path'; 19 | import yaml from 'yaml'; 20 | 21 | 22 | 23 | /* 24 | Path to Solana CLI config file. 25 | */ 26 | const CONFIG_FILE_PATH = path.resolve( 27 | os.homedir(), 28 | '.config', 29 | 'solana', 30 | 'cli', 31 | 'config.yml', 32 | ); 33 | 34 | 35 | let connection: Connection; 36 | let localKeypair: Keypair; 37 | let programKeypair: Keypair; 38 | let programId: PublicKey; 39 | let clientPubKey: PublicKey; 40 | 41 | 42 | const PROGRAM_PATH = path.resolve(__dirname, '../../dist/program'); 43 | 44 | 45 | /* 46 | Connect to dev net. 47 | */ 48 | export async function connect() { 49 | connection = new Connection('https://api.devnet.solana.com', 'confirmed'); 50 | 51 | console.log(`Successfully connected to Solana dev net.`); 52 | } 53 | 54 | 55 | /* 56 | Use local keypair for client. 57 | */ 58 | export async function getLocalAccount() { 59 | const configYml = await fs.readFile(CONFIG_FILE_PATH, {encoding: 'utf8'}); 60 | const keypairPath = await yaml.parse(configYml).keypair_path; 61 | localKeypair = await createKeypairFromFile(keypairPath); 62 | // const airdropRequest = await connection.requestAirdrop( 63 | // localKeypair.publicKey, 64 | // LAMPORTS_PER_SOL*2, 65 | // ); 66 | // await connection.confirmTransaction(airdropRequest); 67 | 68 | console.log(`Local account loaded successfully.`); 69 | console.log(`Local account's address is:`); 70 | console.log(` ${localKeypair.publicKey}`); 71 | } 72 | 73 | 74 | /* 75 | Get the targeted program. 76 | */ 77 | export async function getProgram(programName: string) { 78 | programKeypair = await createKeypairFromFile( 79 | path.join(PROGRAM_PATH, programName + '-keypair.json') 80 | ); 81 | programId = programKeypair.publicKey; 82 | 83 | console.log(`We're going to ping the ${programName} program.`); 84 | console.log(`It's Program ID is:`); 85 | console.log(` ${programId.toBase58()}`) 86 | } 87 | 88 | 89 | /* 90 | Configure client account. 91 | */ 92 | export async function configureClientAccount(accountSpaceSize: number) { 93 | const SEED = 'test7'; 94 | clientPubKey = await PublicKey.createWithSeed( 95 | localKeypair.publicKey, 96 | SEED, 97 | programId, 98 | ); 99 | 100 | console.log(`For simplicity's sake, we've created an address using a seed.`); 101 | console.log(`That seed is just the string "test(num)".`); 102 | console.log(`The generated address is:`); 103 | console.log(` ${clientPubKey.toBase58()}`); 104 | 105 | // Make sure it doesn't exist already. 106 | const clientAccount = await connection.getAccountInfo(clientPubKey); 107 | if (clientAccount === null) { 108 | 109 | console.log(`Looks like that account does not exist. Let's create it.`); 110 | 111 | const transaction = new Transaction().add( 112 | SystemProgram.createAccountWithSeed({ 113 | fromPubkey: localKeypair.publicKey, 114 | basePubkey: localKeypair.publicKey, 115 | seed: SEED, 116 | newAccountPubkey: clientPubKey, 117 | lamports: LAMPORTS_PER_SOL, 118 | space: accountSpaceSize, 119 | programId, 120 | }), 121 | ); 122 | await sendAndConfirmTransaction(connection, transaction, [localKeypair]); 123 | 124 | console.log(`Client account created successfully.`); 125 | } else { 126 | console.log(`Looks like that account exists already. We can just use it.`); 127 | } 128 | } 129 | 130 | 131 | /* 132 | Ping the program. 133 | */ 134 | export async function pingProgram( 135 | operation: number, operatingValue: number) { 136 | 137 | console.log(`All right, let's run it.`); 138 | console.log(`Pinging our calculator program...`); 139 | 140 | let calcInstructions = await createCalculatorInstructions( 141 | operation, operatingValue 142 | ); 143 | 144 | console.log(`We're going to ${await getStringForInstruction(operation, operatingValue)}`) 145 | 146 | const instruction = new TransactionInstruction({ 147 | keys: [{pubkey: clientPubKey, isSigner: false, isWritable: true}], 148 | programId, 149 | data: calcInstructions, 150 | }); 151 | await sendAndConfirmTransaction( 152 | connection, 153 | new Transaction().add(instruction), 154 | [localKeypair], 155 | ); 156 | 157 | console.log(`Ping successful.`); 158 | } 159 | 160 | 161 | /* 162 | Run the example (main). 163 | */ 164 | export async function example(programName: string, accountSpaceSize: number) { 165 | await connect(); 166 | await getLocalAccount(); 167 | await getProgram(programName); 168 | await configureClientAccount(accountSpaceSize); 169 | await pingProgram(1, 4); // Add 4 170 | await pingProgram(2, 1); // Subtract 1 171 | await pingProgram(3, 2); // Multiply by 2 172 | } -------------------------------------------------------------------------------- /nfts/sell-nft/programs/mint-nft/src/mint.rs: -------------------------------------------------------------------------------- 1 | use { 2 | anchor_lang::{ 3 | prelude::*, 4 | solana_program::program::invoke, 5 | system_program, 6 | }, 7 | anchor_spl::{ 8 | associated_token, 9 | token, 10 | }, 11 | mpl_token_metadata::{ 12 | ID as TOKEN_METADATA_ID, 13 | instruction as token_instruction, 14 | }, 15 | }; 16 | 17 | 18 | pub fn mint( 19 | ctx: Context, 20 | metadata_title: String, 21 | metadata_symbol: String, 22 | metadata_uri: String, 23 | ) -> Result<()> { 24 | 25 | msg!("Creating mint account..."); 26 | msg!("Mint: {}", &ctx.accounts.mint.key()); 27 | system_program::create_account( 28 | CpiContext::new( 29 | ctx.accounts.token_program.to_account_info(), 30 | system_program::CreateAccount { 31 | from: ctx.accounts.mint_authority.to_account_info(), 32 | to: ctx.accounts.mint.to_account_info(), 33 | }, 34 | ), 35 | 10000000, 36 | 82, 37 | &ctx.accounts.token_program.key(), 38 | )?; 39 | 40 | msg!("Initializing mint account..."); 41 | msg!("Mint: {}", &ctx.accounts.mint.key()); 42 | token::initialize_mint( 43 | CpiContext::new( 44 | ctx.accounts.token_program.to_account_info(), 45 | token::InitializeMint { 46 | mint: ctx.accounts.mint.to_account_info(), 47 | rent: ctx.accounts.rent.to_account_info(), 48 | }, 49 | ), 50 | 0, 51 | &ctx.accounts.mint_authority.key(), 52 | Some(&ctx.accounts.mint_authority.key()), 53 | )?; 54 | 55 | msg!("Creating token account..."); 56 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 57 | associated_token::create( 58 | CpiContext::new( 59 | ctx.accounts.associated_token_program.to_account_info(), 60 | associated_token::Create { 61 | payer: ctx.accounts.mint_authority.to_account_info(), 62 | associated_token: ctx.accounts.token_account.to_account_info(), 63 | authority: ctx.accounts.mint_authority.to_account_info(), 64 | mint: ctx.accounts.mint.to_account_info(), 65 | system_program: ctx.accounts.system_program.to_account_info(), 66 | token_program: ctx.accounts.token_program.to_account_info(), 67 | rent: ctx.accounts.rent.to_account_info(), 68 | }, 69 | ), 70 | )?; 71 | 72 | msg!("Minting token to token account..."); 73 | msg!("Mint: {}", &ctx.accounts.mint.to_account_info().key()); 74 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 75 | token::mint_to( 76 | CpiContext::new( 77 | ctx.accounts.token_program.to_account_info(), 78 | token::MintTo { 79 | mint: ctx.accounts.mint.to_account_info(), 80 | to: ctx.accounts.token_account.to_account_info(), 81 | authority: ctx.accounts.mint_authority.to_account_info(), 82 | }, 83 | ), 84 | 1, 85 | )?; 86 | 87 | msg!("Creating metadata account..."); 88 | msg!("Metadata account address: {}", &ctx.accounts.metadata.to_account_info().key()); 89 | invoke( 90 | &token_instruction::create_metadata_accounts_v2( 91 | TOKEN_METADATA_ID, 92 | ctx.accounts.metadata.key(), 93 | ctx.accounts.mint.key(), 94 | ctx.accounts.mint_authority.key(), 95 | ctx.accounts.mint_authority.key(), 96 | ctx.accounts.mint_authority.key(), 97 | metadata_title, 98 | metadata_symbol, 99 | metadata_uri, 100 | None, 101 | 1, 102 | true, 103 | false, 104 | None, 105 | None, 106 | ), 107 | &[ 108 | ctx.accounts.metadata.to_account_info(), 109 | ctx.accounts.mint.to_account_info(), 110 | ctx.accounts.token_account.to_account_info(), 111 | ctx.accounts.mint_authority.to_account_info(), 112 | ctx.accounts.rent.to_account_info(), 113 | ], 114 | )?; 115 | 116 | msg!("Creating master edition metadata account..."); 117 | msg!("Master edition metadata account address: {}", &ctx.accounts.master_edition.to_account_info().key()); 118 | invoke( 119 | &token_instruction::create_master_edition_v3( 120 | TOKEN_METADATA_ID, 121 | ctx.accounts.master_edition.key(), 122 | ctx.accounts.mint.key(), 123 | ctx.accounts.mint_authority.key(), 124 | ctx.accounts.mint_authority.key(), 125 | ctx.accounts.metadata.key(), 126 | ctx.accounts.mint_authority.key(), 127 | Some(0), 128 | ), 129 | &[ 130 | ctx.accounts.master_edition.to_account_info(), 131 | ctx.accounts.metadata.to_account_info(), 132 | ctx.accounts.mint.to_account_info(), 133 | ctx.accounts.token_account.to_account_info(), 134 | ctx.accounts.mint_authority.to_account_info(), 135 | ctx.accounts.rent.to_account_info(), 136 | ], 137 | )?; 138 | 139 | msg!("Token mint process completed successfully."); 140 | 141 | Ok(()) 142 | } 143 | 144 | 145 | #[derive(Accounts)] 146 | pub struct MintNft<'info> { 147 | /// CHECK: We're about to create this with Metaplex 148 | #[account(mut)] 149 | pub metadata: UncheckedAccount<'info>, 150 | /// CHECK: We're about to create this with Metaplex 151 | #[account(mut)] 152 | pub master_edition: UncheckedAccount<'info>, 153 | #[account(mut)] 154 | pub mint: Signer<'info>, 155 | /// CHECK: We're about to create this with Anchor 156 | #[account(mut)] 157 | pub token_account: UncheckedAccount<'info>, 158 | #[account(mut)] 159 | pub mint_authority: Signer<'info>, 160 | pub rent: Sysvar<'info, Rent>, 161 | pub system_program: Program<'info, System>, 162 | pub token_program: Program<'info, token::Token>, 163 | pub associated_token_program: Program<'info, associated_token::AssociatedToken>, 164 | /// CHECK: Metaplex will check this 165 | pub token_metadata_program: UncheckedAccount<'info>, 166 | } -------------------------------------------------------------------------------- /nfts/nft-collection/anchor/programs/nft-collection/src/mint.rs: -------------------------------------------------------------------------------- 1 | use { 2 | anchor_lang::{ 3 | prelude::*, 4 | solana_program::program::invoke, 5 | system_program, 6 | }, 7 | anchor_spl::{ 8 | associated_token, 9 | token, 10 | }, 11 | mpl_token_metadata::{ 12 | ID as TOKEN_METADATA_ID, 13 | instruction as token_instruction, 14 | }, 15 | }; 16 | 17 | 18 | pub fn mint( 19 | ctx: Context, 20 | metadata_title: String, 21 | metadata_symbol: String, 22 | metadata_uri: String, 23 | ) -> Result<()> { 24 | 25 | msg!("Creating mint account..."); 26 | msg!("Mint: {}", &ctx.accounts.mint.key()); 27 | system_program::create_account( 28 | CpiContext::new( 29 | ctx.accounts.token_program.to_account_info(), 30 | system_program::CreateAccount { 31 | from: ctx.accounts.mint_authority.to_account_info(), 32 | to: ctx.accounts.mint.to_account_info(), 33 | }, 34 | ), 35 | 10000000, 36 | 82, 37 | &ctx.accounts.token_program.key(), 38 | )?; 39 | 40 | msg!("Initializing mint account..."); 41 | msg!("Mint: {}", &ctx.accounts.mint.key()); 42 | token::initialize_mint( 43 | CpiContext::new( 44 | ctx.accounts.token_program.to_account_info(), 45 | token::InitializeMint { 46 | mint: ctx.accounts.mint.to_account_info(), 47 | rent: ctx.accounts.rent.to_account_info(), 48 | }, 49 | ), 50 | 0, 51 | &ctx.accounts.mint_authority.key(), 52 | Some(&ctx.accounts.mint_authority.key()), 53 | )?; 54 | 55 | msg!("Creating token account..."); 56 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 57 | associated_token::create( 58 | CpiContext::new( 59 | ctx.accounts.associated_token_program.to_account_info(), 60 | associated_token::Create { 61 | payer: ctx.accounts.mint_authority.to_account_info(), 62 | associated_token: ctx.accounts.token_account.to_account_info(), 63 | authority: ctx.accounts.mint_authority.to_account_info(), 64 | mint: ctx.accounts.mint.to_account_info(), 65 | system_program: ctx.accounts.system_program.to_account_info(), 66 | token_program: ctx.accounts.token_program.to_account_info(), 67 | rent: ctx.accounts.rent.to_account_info(), 68 | }, 69 | ), 70 | )?; 71 | 72 | msg!("Minting token to token account..."); 73 | msg!("Mint: {}", &ctx.accounts.mint.to_account_info().key()); 74 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 75 | token::mint_to( 76 | CpiContext::new( 77 | ctx.accounts.token_program.to_account_info(), 78 | token::MintTo { 79 | mint: ctx.accounts.mint.to_account_info(), 80 | to: ctx.accounts.token_account.to_account_info(), 81 | authority: ctx.accounts.mint_authority.to_account_info(), 82 | }, 83 | ), 84 | 1, 85 | )?; 86 | 87 | msg!("Creating metadata account..."); 88 | msg!("Metadata account address: {}", &ctx.accounts.metadata.to_account_info().key()); 89 | invoke( 90 | &token_instruction::create_metadata_accounts_v2( 91 | TOKEN_METADATA_ID, 92 | ctx.accounts.metadata.key(), 93 | ctx.accounts.mint.key(), 94 | ctx.accounts.mint_authority.key(), 95 | ctx.accounts.mint_authority.key(), 96 | ctx.accounts.mint_authority.key(), 97 | metadata_title, 98 | metadata_symbol, 99 | metadata_uri, 100 | None, 101 | 1, 102 | true, 103 | false, 104 | None, 105 | None, 106 | ), 107 | &[ 108 | ctx.accounts.metadata.to_account_info(), 109 | ctx.accounts.mint.to_account_info(), 110 | ctx.accounts.token_account.to_account_info(), 111 | ctx.accounts.mint_authority.to_account_info(), 112 | ctx.accounts.rent.to_account_info(), 113 | ], 114 | )?; 115 | 116 | msg!("Creating master edition metadata account..."); 117 | msg!("Master edition metadata account address: {}", &ctx.accounts.master_edition.to_account_info().key()); 118 | invoke( 119 | &token_instruction::create_master_edition_v3( 120 | TOKEN_METADATA_ID, 121 | ctx.accounts.master_edition.key(), 122 | ctx.accounts.mint.key(), 123 | ctx.accounts.mint_authority.key(), 124 | ctx.accounts.mint_authority.key(), 125 | ctx.accounts.metadata.key(), 126 | ctx.accounts.mint_authority.key(), 127 | Some(0), 128 | ), 129 | &[ 130 | ctx.accounts.master_edition.to_account_info(), 131 | ctx.accounts.metadata.to_account_info(), 132 | ctx.accounts.mint.to_account_info(), 133 | ctx.accounts.token_account.to_account_info(), 134 | ctx.accounts.mint_authority.to_account_info(), 135 | ctx.accounts.rent.to_account_info(), 136 | ], 137 | )?; 138 | 139 | msg!("Token mint process completed successfully."); 140 | 141 | Ok(()) 142 | } 143 | 144 | 145 | #[derive(Accounts)] 146 | pub struct MintNft<'info> { 147 | /// CHECK: We're about to create this with Metaplex 148 | #[account(mut)] 149 | pub metadata: UncheckedAccount<'info>, 150 | /// CHECK: We're about to create this with Metaplex 151 | #[account(mut)] 152 | pub master_edition: UncheckedAccount<'info>, 153 | #[account(mut)] 154 | pub mint: Signer<'info>, 155 | /// CHECK: We're about to create this with Anchor 156 | #[account(mut)] 157 | pub token_account: UncheckedAccount<'info>, 158 | #[account(mut)] 159 | pub mint_authority: Signer<'info>, 160 | pub rent: Sysvar<'info, Rent>, 161 | pub system_program: Program<'info, System>, 162 | pub token_program: Program<'info, token::Token>, 163 | pub associated_token_program: Program<'info, associated_token::AssociatedToken>, 164 | /// CHECK: Metaplex will check this 165 | pub token_metadata_program: UncheckedAccount<'info>, 166 | } -------------------------------------------------------------------------------- /nfts/mint-nft/programs/mint-nft/src/lib.rs: -------------------------------------------------------------------------------- 1 | use { 2 | anchor_lang::{ 3 | prelude::*, 4 | solana_program::program::invoke, 5 | system_program, 6 | }, 7 | anchor_spl::{ 8 | associated_token, 9 | token, 10 | }, 11 | mpl_token_metadata::{ 12 | ID as TOKEN_METADATA_ID, 13 | instruction as token_instruction, 14 | }, 15 | }; 16 | 17 | 18 | declare_id!("BQ31J31Mb1qK1dVjYyxq6Q6B2NrW72qaGQrTxuTPQJGM"); 19 | 20 | 21 | #[program] 22 | pub mod mint_nft { 23 | use super::*; 24 | 25 | pub fn mint( 26 | ctx: Context, 27 | metadata_title: String, 28 | metadata_symbol: String, 29 | metadata_uri: String, 30 | ) -> Result<()> { 31 | 32 | msg!("Creating mint account..."); 33 | msg!("Mint: {}", &ctx.accounts.mint.key()); 34 | system_program::create_account( 35 | CpiContext::new( 36 | ctx.accounts.token_program.to_account_info(), 37 | system_program::CreateAccount { 38 | from: ctx.accounts.mint_authority.to_account_info(), 39 | to: ctx.accounts.mint.to_account_info(), 40 | }, 41 | ), 42 | 10000000, 43 | 82, 44 | &ctx.accounts.token_program.key(), 45 | )?; 46 | 47 | msg!("Initializing mint account..."); 48 | msg!("Mint: {}", &ctx.accounts.mint.key()); 49 | token::initialize_mint( 50 | CpiContext::new( 51 | ctx.accounts.token_program.to_account_info(), 52 | token::InitializeMint { 53 | mint: ctx.accounts.mint.to_account_info(), 54 | rent: ctx.accounts.rent.to_account_info(), 55 | }, 56 | ), 57 | 0, 58 | &ctx.accounts.mint_authority.key(), 59 | Some(&ctx.accounts.mint_authority.key()), 60 | )?; 61 | 62 | msg!("Creating token account..."); 63 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 64 | associated_token::create( 65 | CpiContext::new( 66 | ctx.accounts.associated_token_program.to_account_info(), 67 | associated_token::Create { 68 | payer: ctx.accounts.mint_authority.to_account_info(), 69 | associated_token: ctx.accounts.token_account.to_account_info(), 70 | authority: ctx.accounts.mint_authority.to_account_info(), 71 | mint: ctx.accounts.mint.to_account_info(), 72 | system_program: ctx.accounts.system_program.to_account_info(), 73 | token_program: ctx.accounts.token_program.to_account_info(), 74 | rent: ctx.accounts.rent.to_account_info(), 75 | }, 76 | ), 77 | )?; 78 | 79 | msg!("Minting token to token account..."); 80 | msg!("Mint: {}", &ctx.accounts.mint.to_account_info().key()); 81 | msg!("Token Address: {}", &ctx.accounts.token_account.key()); 82 | token::mint_to( 83 | CpiContext::new( 84 | ctx.accounts.token_program.to_account_info(), 85 | token::MintTo { 86 | mint: ctx.accounts.mint.to_account_info(), 87 | to: ctx.accounts.token_account.to_account_info(), 88 | authority: ctx.accounts.mint_authority.to_account_info(), 89 | }, 90 | ), 91 | 1, 92 | )?; 93 | 94 | msg!("Creating metadata account..."); 95 | msg!("Metadata account address: {}", &ctx.accounts.metadata.to_account_info().key()); 96 | invoke( 97 | &token_instruction::create_metadata_accounts_v2( 98 | TOKEN_METADATA_ID, 99 | ctx.accounts.metadata.key(), 100 | ctx.accounts.mint.key(), 101 | ctx.accounts.mint_authority.key(), 102 | ctx.accounts.mint_authority.key(), 103 | ctx.accounts.mint_authority.key(), 104 | metadata_title, 105 | metadata_symbol, 106 | metadata_uri, 107 | None, 108 | 1, 109 | true, 110 | false, 111 | None, 112 | None, 113 | ), 114 | &[ 115 | ctx.accounts.metadata.to_account_info(), 116 | ctx.accounts.mint.to_account_info(), 117 | ctx.accounts.token_account.to_account_info(), 118 | ctx.accounts.mint_authority.to_account_info(), 119 | ctx.accounts.rent.to_account_info(), 120 | ], 121 | )?; 122 | 123 | msg!("Creating master edition metadata account..."); 124 | msg!("Master edition metadata account address: {}", &ctx.accounts.master_edition.to_account_info().key()); 125 | invoke( 126 | &token_instruction::create_master_edition_v3( 127 | TOKEN_METADATA_ID, 128 | ctx.accounts.master_edition.key(), 129 | ctx.accounts.mint.key(), 130 | ctx.accounts.mint_authority.key(), 131 | ctx.accounts.mint_authority.key(), 132 | ctx.accounts.metadata.key(), 133 | ctx.accounts.mint_authority.key(), 134 | Some(0), 135 | ), 136 | &[ 137 | ctx.accounts.master_edition.to_account_info(), 138 | ctx.accounts.metadata.to_account_info(), 139 | ctx.accounts.mint.to_account_info(), 140 | ctx.accounts.token_account.to_account_info(), 141 | ctx.accounts.mint_authority.to_account_info(), 142 | ctx.accounts.rent.to_account_info(), 143 | ], 144 | )?; 145 | 146 | msg!("Token mint process completed successfully."); 147 | 148 | Ok(()) 149 | } 150 | } 151 | 152 | 153 | #[derive(Accounts)] 154 | pub struct MintNft<'info> { 155 | /// CHECK: We're about to create this with Metaplex 156 | #[account(mut)] 157 | pub metadata: UncheckedAccount<'info>, 158 | /// CHECK: We're about to create this with Metaplex 159 | #[account(mut)] 160 | pub master_edition: UncheckedAccount<'info>, 161 | #[account(mut)] 162 | pub mint: Signer<'info>, 163 | /// CHECK: We're about to create this with Anchor 164 | #[account(mut)] 165 | pub token_account: UncheckedAccount<'info>, 166 | #[account(mut)] 167 | pub mint_authority: Signer<'info>, 168 | pub rent: Sysvar<'info, Rent>, 169 | pub system_program: Program<'info, System>, 170 | pub token_program: Program<'info, token::Token>, 171 | pub associated_token_program: Program<'info, associated_token::AssociatedToken>, 172 | /// CHECK: Metaplex will check this 173 | pub token_metadata_program: UncheckedAccount<'info>, 174 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2024 Joe Caulfield 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | -------------------------------------------------------------------------------- /pdas/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ahash" 7 | version = "0.7.6" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 10 | dependencies = [ 11 | "getrandom 0.2.7", 12 | "once_cell", 13 | "version_check", 14 | ] 15 | 16 | [[package]] 17 | name = "aho-corasick" 18 | version = "0.7.18" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 21 | dependencies = [ 22 | "memchr", 23 | ] 24 | 25 | [[package]] 26 | name = "anchor-attribute-access-control" 27 | version = "0.24.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "a9b75d05b6b4ac9d95bb6e3b786b27d3a708c4c5a87c92ffaa25bbe9ae4c5d91" 30 | dependencies = [ 31 | "anchor-syn", 32 | "anyhow", 33 | "proc-macro2", 34 | "quote", 35 | "regex", 36 | "syn", 37 | ] 38 | 39 | [[package]] 40 | name = "anchor-attribute-account" 41 | version = "0.24.2" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "485351a6d8157750d10d88c8e256f1bf8339262b2220ae9125aed3471309b5de" 44 | dependencies = [ 45 | "anchor-syn", 46 | "anyhow", 47 | "bs58 0.4.0", 48 | "proc-macro2", 49 | "quote", 50 | "rustversion", 51 | "syn", 52 | ] 53 | 54 | [[package]] 55 | name = "anchor-attribute-constant" 56 | version = "0.24.2" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "dc632c540913dd051a78b00587cc47f57013d303163ddfaf4fa18717f7ccc1e0" 59 | dependencies = [ 60 | "anchor-syn", 61 | "proc-macro2", 62 | "syn", 63 | ] 64 | 65 | [[package]] 66 | name = "anchor-attribute-error" 67 | version = "0.24.2" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "3b5bd1dcfa7f3bc22dacef233d70a9e0bee269c4ac484510662f257cba2353a1" 70 | dependencies = [ 71 | "anchor-syn", 72 | "proc-macro2", 73 | "quote", 74 | "syn", 75 | ] 76 | 77 | [[package]] 78 | name = "anchor-attribute-event" 79 | version = "0.24.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "6c6f9e6ce551ac9a177a45c99a65699a860c9e95fac68675138af1246e2591b0" 82 | dependencies = [ 83 | "anchor-syn", 84 | "anyhow", 85 | "proc-macro2", 86 | "quote", 87 | "syn", 88 | ] 89 | 90 | [[package]] 91 | name = "anchor-attribute-interface" 92 | version = "0.24.2" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "d104aa17418cb329ed7418b227e083d5f326a27f26ce98f5d92e33da62a5f459" 95 | dependencies = [ 96 | "anchor-syn", 97 | "anyhow", 98 | "heck", 99 | "proc-macro2", 100 | "quote", 101 | "syn", 102 | ] 103 | 104 | [[package]] 105 | name = "anchor-attribute-program" 106 | version = "0.24.2" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "b6831b920b173c004ddf7ae1167d1d25e9f002ffcb1773bbc5c7ce532a4441e1" 109 | dependencies = [ 110 | "anchor-syn", 111 | "anyhow", 112 | "proc-macro2", 113 | "quote", 114 | "syn", 115 | ] 116 | 117 | [[package]] 118 | name = "anchor-attribute-state" 119 | version = "0.24.2" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "cde147b10c71d95dc679785db0b5f3abac0091f789167aa62ac0135e2f54e8b9" 122 | dependencies = [ 123 | "anchor-syn", 124 | "anyhow", 125 | "proc-macro2", 126 | "quote", 127 | "syn", 128 | ] 129 | 130 | [[package]] 131 | name = "anchor-derive-accounts" 132 | version = "0.24.2" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "9cde98a0e1a56046b040ff591dfda391f88917af2b6487d02b45093c05be3514" 135 | dependencies = [ 136 | "anchor-syn", 137 | "anyhow", 138 | "proc-macro2", 139 | "quote", 140 | "syn", 141 | ] 142 | 143 | [[package]] 144 | name = "anchor-lang" 145 | version = "0.24.2" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | checksum = "a85dd2c5e29e20c7f4701a43724d6cd5406d0ee5694705522e43da0f26542a84" 148 | dependencies = [ 149 | "anchor-attribute-access-control", 150 | "anchor-attribute-account", 151 | "anchor-attribute-constant", 152 | "anchor-attribute-error", 153 | "anchor-attribute-event", 154 | "anchor-attribute-interface", 155 | "anchor-attribute-program", 156 | "anchor-attribute-state", 157 | "anchor-derive-accounts", 158 | "arrayref", 159 | "base64 0.13.0", 160 | "bincode", 161 | "borsh", 162 | "bytemuck", 163 | "solana-program", 164 | "thiserror", 165 | ] 166 | 167 | [[package]] 168 | name = "anchor-syn" 169 | version = "0.24.2" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "03549dc2eae0b20beba6333b14520e511822a6321cdb1760f841064a69347316" 172 | dependencies = [ 173 | "anyhow", 174 | "bs58 0.3.1", 175 | "heck", 176 | "proc-macro2", 177 | "proc-macro2-diagnostics", 178 | "quote", 179 | "serde", 180 | "serde_json", 181 | "sha2", 182 | "syn", 183 | "thiserror", 184 | ] 185 | 186 | [[package]] 187 | name = "anyhow" 188 | version = "1.0.58" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" 191 | 192 | [[package]] 193 | name = "arrayref" 194 | version = "0.3.6" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" 197 | 198 | [[package]] 199 | name = "arrayvec" 200 | version = "0.7.2" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" 203 | 204 | [[package]] 205 | name = "atty" 206 | version = "0.2.14" 207 | source = "registry+https://github.com/rust-lang/crates.io-index" 208 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 209 | dependencies = [ 210 | "hermit-abi", 211 | "libc", 212 | "winapi", 213 | ] 214 | 215 | [[package]] 216 | name = "autocfg" 217 | version = "1.1.0" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 220 | 221 | [[package]] 222 | name = "base64" 223 | version = "0.12.3" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" 226 | 227 | [[package]] 228 | name = "base64" 229 | version = "0.13.0" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 232 | 233 | [[package]] 234 | name = "bincode" 235 | version = "1.3.3" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 238 | dependencies = [ 239 | "serde", 240 | ] 241 | 242 | [[package]] 243 | name = "bitflags" 244 | version = "1.3.2" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 247 | 248 | [[package]] 249 | name = "blake3" 250 | version = "1.3.1" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" 253 | dependencies = [ 254 | "arrayref", 255 | "arrayvec", 256 | "cc", 257 | "cfg-if", 258 | "constant_time_eq", 259 | "digest 0.10.3", 260 | ] 261 | 262 | [[package]] 263 | name = "block-buffer" 264 | version = "0.9.0" 265 | source = "registry+https://github.com/rust-lang/crates.io-index" 266 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" 267 | dependencies = [ 268 | "block-padding", 269 | "generic-array", 270 | ] 271 | 272 | [[package]] 273 | name = "block-buffer" 274 | version = "0.10.2" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" 277 | dependencies = [ 278 | "generic-array", 279 | ] 280 | 281 | [[package]] 282 | name = "block-padding" 283 | version = "0.2.1" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" 286 | 287 | [[package]] 288 | name = "borsh" 289 | version = "0.9.3" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" 292 | dependencies = [ 293 | "borsh-derive", 294 | "hashbrown", 295 | ] 296 | 297 | [[package]] 298 | name = "borsh-derive" 299 | version = "0.9.3" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" 302 | dependencies = [ 303 | "borsh-derive-internal", 304 | "borsh-schema-derive-internal", 305 | "proc-macro-crate", 306 | "proc-macro2", 307 | "syn", 308 | ] 309 | 310 | [[package]] 311 | name = "borsh-derive-internal" 312 | version = "0.9.3" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" 315 | dependencies = [ 316 | "proc-macro2", 317 | "quote", 318 | "syn", 319 | ] 320 | 321 | [[package]] 322 | name = "borsh-schema-derive-internal" 323 | version = "0.9.3" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" 326 | dependencies = [ 327 | "proc-macro2", 328 | "quote", 329 | "syn", 330 | ] 331 | 332 | [[package]] 333 | name = "bs58" 334 | version = "0.3.1" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" 337 | 338 | [[package]] 339 | name = "bs58" 340 | version = "0.4.0" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" 343 | 344 | [[package]] 345 | name = "bumpalo" 346 | version = "3.10.0" 347 | source = "registry+https://github.com/rust-lang/crates.io-index" 348 | checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" 349 | 350 | [[package]] 351 | name = "bv" 352 | version = "0.11.1" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" 355 | dependencies = [ 356 | "feature-probe", 357 | "serde", 358 | ] 359 | 360 | [[package]] 361 | name = "bytemuck" 362 | version = "1.9.1" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" 365 | dependencies = [ 366 | "bytemuck_derive", 367 | ] 368 | 369 | [[package]] 370 | name = "bytemuck_derive" 371 | version = "1.1.0" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "562e382481975bc61d11275ac5e62a19abd00b0547d99516a415336f183dcd0e" 374 | dependencies = [ 375 | "proc-macro2", 376 | "quote", 377 | "syn", 378 | ] 379 | 380 | [[package]] 381 | name = "byteorder" 382 | version = "1.4.3" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 385 | 386 | [[package]] 387 | name = "cc" 388 | version = "1.0.73" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 391 | 392 | [[package]] 393 | name = "cfg-if" 394 | version = "1.0.0" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 397 | 398 | [[package]] 399 | name = "console_error_panic_hook" 400 | version = "0.1.7" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 403 | dependencies = [ 404 | "cfg-if", 405 | "wasm-bindgen", 406 | ] 407 | 408 | [[package]] 409 | name = "console_log" 410 | version = "0.2.0" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" 413 | dependencies = [ 414 | "log", 415 | "web-sys", 416 | ] 417 | 418 | [[package]] 419 | name = "constant_time_eq" 420 | version = "0.1.5" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" 423 | 424 | [[package]] 425 | name = "cpufeatures" 426 | version = "0.2.2" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" 429 | dependencies = [ 430 | "libc", 431 | ] 432 | 433 | [[package]] 434 | name = "crunchy" 435 | version = "0.2.2" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 438 | 439 | [[package]] 440 | name = "crypto-common" 441 | version = "0.1.3" 442 | source = "registry+https://github.com/rust-lang/crates.io-index" 443 | checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" 444 | dependencies = [ 445 | "generic-array", 446 | "typenum", 447 | ] 448 | 449 | [[package]] 450 | name = "crypto-mac" 451 | version = "0.8.0" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" 454 | dependencies = [ 455 | "generic-array", 456 | "subtle", 457 | ] 458 | 459 | [[package]] 460 | name = "curve25519-dalek" 461 | version = "3.2.1" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" 464 | dependencies = [ 465 | "byteorder", 466 | "digest 0.9.0", 467 | "rand_core", 468 | "subtle", 469 | "zeroize", 470 | ] 471 | 472 | [[package]] 473 | name = "digest" 474 | version = "0.9.0" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 477 | dependencies = [ 478 | "generic-array", 479 | ] 480 | 481 | [[package]] 482 | name = "digest" 483 | version = "0.10.3" 484 | source = "registry+https://github.com/rust-lang/crates.io-index" 485 | checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" 486 | dependencies = [ 487 | "block-buffer 0.10.2", 488 | "crypto-common", 489 | "subtle", 490 | ] 491 | 492 | [[package]] 493 | name = "either" 494 | version = "1.6.1" 495 | source = "registry+https://github.com/rust-lang/crates.io-index" 496 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 497 | 498 | [[package]] 499 | name = "env_logger" 500 | version = "0.9.0" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" 503 | dependencies = [ 504 | "atty", 505 | "humantime", 506 | "log", 507 | "regex", 508 | "termcolor", 509 | ] 510 | 511 | [[package]] 512 | name = "feature-probe" 513 | version = "0.1.1" 514 | source = "registry+https://github.com/rust-lang/crates.io-index" 515 | checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" 516 | 517 | [[package]] 518 | name = "generic-array" 519 | version = "0.14.5" 520 | source = "registry+https://github.com/rust-lang/crates.io-index" 521 | checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" 522 | dependencies = [ 523 | "serde", 524 | "typenum", 525 | "version_check", 526 | ] 527 | 528 | [[package]] 529 | name = "getrandom" 530 | version = "0.1.16" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" 533 | dependencies = [ 534 | "cfg-if", 535 | "js-sys", 536 | "libc", 537 | "wasi 0.9.0+wasi-snapshot-preview1", 538 | "wasm-bindgen", 539 | ] 540 | 541 | [[package]] 542 | name = "getrandom" 543 | version = "0.2.7" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 546 | dependencies = [ 547 | "cfg-if", 548 | "libc", 549 | "wasi 0.11.0+wasi-snapshot-preview1", 550 | ] 551 | 552 | [[package]] 553 | name = "hashbrown" 554 | version = "0.11.2" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 557 | dependencies = [ 558 | "ahash", 559 | ] 560 | 561 | [[package]] 562 | name = "heck" 563 | version = "0.3.3" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 566 | dependencies = [ 567 | "unicode-segmentation", 568 | ] 569 | 570 | [[package]] 571 | name = "hermit-abi" 572 | version = "0.1.19" 573 | source = "registry+https://github.com/rust-lang/crates.io-index" 574 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 575 | dependencies = [ 576 | "libc", 577 | ] 578 | 579 | [[package]] 580 | name = "hmac" 581 | version = "0.8.1" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" 584 | dependencies = [ 585 | "crypto-mac", 586 | "digest 0.9.0", 587 | ] 588 | 589 | [[package]] 590 | name = "hmac-drbg" 591 | version = "0.3.0" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" 594 | dependencies = [ 595 | "digest 0.9.0", 596 | "generic-array", 597 | "hmac", 598 | ] 599 | 600 | [[package]] 601 | name = "humantime" 602 | version = "2.1.0" 603 | source = "registry+https://github.com/rust-lang/crates.io-index" 604 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 605 | 606 | [[package]] 607 | name = "instant" 608 | version = "0.1.12" 609 | source = "registry+https://github.com/rust-lang/crates.io-index" 610 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 611 | dependencies = [ 612 | "cfg-if", 613 | ] 614 | 615 | [[package]] 616 | name = "itertools" 617 | version = "0.10.3" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 620 | dependencies = [ 621 | "either", 622 | ] 623 | 624 | [[package]] 625 | name = "itoa" 626 | version = "1.0.2" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" 629 | 630 | [[package]] 631 | name = "js-sys" 632 | version = "0.3.58" 633 | source = "registry+https://github.com/rust-lang/crates.io-index" 634 | checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" 635 | dependencies = [ 636 | "wasm-bindgen", 637 | ] 638 | 639 | [[package]] 640 | name = "keccak" 641 | version = "0.1.2" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" 644 | 645 | [[package]] 646 | name = "lazy_static" 647 | version = "1.4.0" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 650 | 651 | [[package]] 652 | name = "libc" 653 | version = "0.2.126" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" 656 | 657 | [[package]] 658 | name = "libsecp256k1" 659 | version = "0.6.0" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" 662 | dependencies = [ 663 | "arrayref", 664 | "base64 0.12.3", 665 | "digest 0.9.0", 666 | "hmac-drbg", 667 | "libsecp256k1-core", 668 | "libsecp256k1-gen-ecmult", 669 | "libsecp256k1-gen-genmult", 670 | "rand", 671 | "serde", 672 | "sha2", 673 | "typenum", 674 | ] 675 | 676 | [[package]] 677 | name = "libsecp256k1-core" 678 | version = "0.2.2" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" 681 | dependencies = [ 682 | "crunchy", 683 | "digest 0.9.0", 684 | "subtle", 685 | ] 686 | 687 | [[package]] 688 | name = "libsecp256k1-gen-ecmult" 689 | version = "0.2.1" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" 692 | dependencies = [ 693 | "libsecp256k1-core", 694 | ] 695 | 696 | [[package]] 697 | name = "libsecp256k1-gen-genmult" 698 | version = "0.2.1" 699 | source = "registry+https://github.com/rust-lang/crates.io-index" 700 | checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" 701 | dependencies = [ 702 | "libsecp256k1-core", 703 | ] 704 | 705 | [[package]] 706 | name = "lock_api" 707 | version = "0.4.7" 708 | source = "registry+https://github.com/rust-lang/crates.io-index" 709 | checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" 710 | dependencies = [ 711 | "autocfg", 712 | "scopeguard", 713 | ] 714 | 715 | [[package]] 716 | name = "log" 717 | version = "0.4.17" 718 | source = "registry+https://github.com/rust-lang/crates.io-index" 719 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 720 | dependencies = [ 721 | "cfg-if", 722 | ] 723 | 724 | [[package]] 725 | name = "memchr" 726 | version = "2.5.0" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 729 | 730 | [[package]] 731 | name = "memmap2" 732 | version = "0.5.4" 733 | source = "registry+https://github.com/rust-lang/crates.io-index" 734 | checksum = "d5172b50c23043ff43dd53e51392f36519d9b35a8f3a410d30ece5d1aedd58ae" 735 | dependencies = [ 736 | "libc", 737 | ] 738 | 739 | [[package]] 740 | name = "num-derive" 741 | version = "0.3.3" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" 744 | dependencies = [ 745 | "proc-macro2", 746 | "quote", 747 | "syn", 748 | ] 749 | 750 | [[package]] 751 | name = "num-traits" 752 | version = "0.2.15" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 755 | dependencies = [ 756 | "autocfg", 757 | ] 758 | 759 | [[package]] 760 | name = "once_cell" 761 | version = "1.12.0" 762 | source = "registry+https://github.com/rust-lang/crates.io-index" 763 | checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" 764 | 765 | [[package]] 766 | name = "opaque-debug" 767 | version = "0.3.0" 768 | source = "registry+https://github.com/rust-lang/crates.io-index" 769 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 770 | 771 | [[package]] 772 | name = "parking_lot" 773 | version = "0.11.2" 774 | source = "registry+https://github.com/rust-lang/crates.io-index" 775 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 776 | dependencies = [ 777 | "instant", 778 | "lock_api", 779 | "parking_lot_core", 780 | ] 781 | 782 | [[package]] 783 | name = "parking_lot_core" 784 | version = "0.8.5" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 787 | dependencies = [ 788 | "cfg-if", 789 | "instant", 790 | "libc", 791 | "redox_syscall", 792 | "smallvec", 793 | "winapi", 794 | ] 795 | 796 | [[package]] 797 | name = "pdas" 798 | version = "0.1.0" 799 | dependencies = [ 800 | "anchor-lang", 801 | ] 802 | 803 | [[package]] 804 | name = "ppv-lite86" 805 | version = "0.2.16" 806 | source = "registry+https://github.com/rust-lang/crates.io-index" 807 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 808 | 809 | [[package]] 810 | name = "proc-macro-crate" 811 | version = "0.1.5" 812 | source = "registry+https://github.com/rust-lang/crates.io-index" 813 | checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" 814 | dependencies = [ 815 | "toml", 816 | ] 817 | 818 | [[package]] 819 | name = "proc-macro2" 820 | version = "1.0.40" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 823 | dependencies = [ 824 | "unicode-ident", 825 | ] 826 | 827 | [[package]] 828 | name = "proc-macro2-diagnostics" 829 | version = "0.9.1" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" 832 | dependencies = [ 833 | "proc-macro2", 834 | "quote", 835 | "syn", 836 | "version_check", 837 | "yansi", 838 | ] 839 | 840 | [[package]] 841 | name = "quote" 842 | version = "1.0.20" 843 | source = "registry+https://github.com/rust-lang/crates.io-index" 844 | checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 845 | dependencies = [ 846 | "proc-macro2", 847 | ] 848 | 849 | [[package]] 850 | name = "rand" 851 | version = "0.7.3" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 854 | dependencies = [ 855 | "getrandom 0.1.16", 856 | "libc", 857 | "rand_chacha", 858 | "rand_core", 859 | "rand_hc", 860 | ] 861 | 862 | [[package]] 863 | name = "rand_chacha" 864 | version = "0.2.2" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 867 | dependencies = [ 868 | "ppv-lite86", 869 | "rand_core", 870 | ] 871 | 872 | [[package]] 873 | name = "rand_core" 874 | version = "0.5.1" 875 | source = "registry+https://github.com/rust-lang/crates.io-index" 876 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 877 | dependencies = [ 878 | "getrandom 0.1.16", 879 | ] 880 | 881 | [[package]] 882 | name = "rand_hc" 883 | version = "0.2.0" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 886 | dependencies = [ 887 | "rand_core", 888 | ] 889 | 890 | [[package]] 891 | name = "redox_syscall" 892 | version = "0.2.13" 893 | source = "registry+https://github.com/rust-lang/crates.io-index" 894 | checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" 895 | dependencies = [ 896 | "bitflags", 897 | ] 898 | 899 | [[package]] 900 | name = "regex" 901 | version = "1.5.6" 902 | source = "registry+https://github.com/rust-lang/crates.io-index" 903 | checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" 904 | dependencies = [ 905 | "aho-corasick", 906 | "memchr", 907 | "regex-syntax", 908 | ] 909 | 910 | [[package]] 911 | name = "regex-syntax" 912 | version = "0.6.26" 913 | source = "registry+https://github.com/rust-lang/crates.io-index" 914 | checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" 915 | 916 | [[package]] 917 | name = "rustc_version" 918 | version = "0.4.0" 919 | source = "registry+https://github.com/rust-lang/crates.io-index" 920 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 921 | dependencies = [ 922 | "semver", 923 | ] 924 | 925 | [[package]] 926 | name = "rustversion" 927 | version = "1.0.7" 928 | source = "registry+https://github.com/rust-lang/crates.io-index" 929 | checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf" 930 | 931 | [[package]] 932 | name = "ryu" 933 | version = "1.0.10" 934 | source = "registry+https://github.com/rust-lang/crates.io-index" 935 | checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" 936 | 937 | [[package]] 938 | name = "scopeguard" 939 | version = "1.1.0" 940 | source = "registry+https://github.com/rust-lang/crates.io-index" 941 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 942 | 943 | [[package]] 944 | name = "semver" 945 | version = "1.0.10" 946 | source = "registry+https://github.com/rust-lang/crates.io-index" 947 | checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c" 948 | 949 | [[package]] 950 | name = "serde" 951 | version = "1.0.137" 952 | source = "registry+https://github.com/rust-lang/crates.io-index" 953 | checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" 954 | dependencies = [ 955 | "serde_derive", 956 | ] 957 | 958 | [[package]] 959 | name = "serde_bytes" 960 | version = "0.11.6" 961 | source = "registry+https://github.com/rust-lang/crates.io-index" 962 | checksum = "212e73464ebcde48d723aa02eb270ba62eff38a9b732df31f33f1b4e145f3a54" 963 | dependencies = [ 964 | "serde", 965 | ] 966 | 967 | [[package]] 968 | name = "serde_derive" 969 | version = "1.0.137" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" 972 | dependencies = [ 973 | "proc-macro2", 974 | "quote", 975 | "syn", 976 | ] 977 | 978 | [[package]] 979 | name = "serde_json" 980 | version = "1.0.81" 981 | source = "registry+https://github.com/rust-lang/crates.io-index" 982 | checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" 983 | dependencies = [ 984 | "itoa", 985 | "ryu", 986 | "serde", 987 | ] 988 | 989 | [[package]] 990 | name = "sha2" 991 | version = "0.9.9" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" 994 | dependencies = [ 995 | "block-buffer 0.9.0", 996 | "cfg-if", 997 | "cpufeatures", 998 | "digest 0.9.0", 999 | "opaque-debug", 1000 | ] 1001 | 1002 | [[package]] 1003 | name = "sha3" 1004 | version = "0.9.1" 1005 | source = "registry+https://github.com/rust-lang/crates.io-index" 1006 | checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" 1007 | dependencies = [ 1008 | "block-buffer 0.9.0", 1009 | "digest 0.9.0", 1010 | "keccak", 1011 | "opaque-debug", 1012 | ] 1013 | 1014 | [[package]] 1015 | name = "smallvec" 1016 | version = "1.8.1" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2" 1019 | 1020 | [[package]] 1021 | name = "solana-frozen-abi" 1022 | version = "1.9.29" 1023 | source = "registry+https://github.com/rust-lang/crates.io-index" 1024 | checksum = "2d4fcb89eb3d0f30bd4b4a31ad1825c9d95cd638509acead00969d7601713288" 1025 | dependencies = [ 1026 | "bs58 0.4.0", 1027 | "bv", 1028 | "generic-array", 1029 | "log", 1030 | "memmap2", 1031 | "rustc_version", 1032 | "serde", 1033 | "serde_derive", 1034 | "sha2", 1035 | "solana-frozen-abi-macro", 1036 | "solana-logger", 1037 | "thiserror", 1038 | ] 1039 | 1040 | [[package]] 1041 | name = "solana-frozen-abi-macro" 1042 | version = "1.9.29" 1043 | source = "registry+https://github.com/rust-lang/crates.io-index" 1044 | checksum = "d63ab101db88ecccd8da34065b9097b88367e0744fdfd05cb7de87b4ede3717f" 1045 | dependencies = [ 1046 | "proc-macro2", 1047 | "quote", 1048 | "rustc_version", 1049 | "syn", 1050 | ] 1051 | 1052 | [[package]] 1053 | name = "solana-logger" 1054 | version = "1.9.29" 1055 | source = "registry+https://github.com/rust-lang/crates.io-index" 1056 | checksum = "9ce1805d52fc8277a84c4803c7850c8f41471b57fb0dec7750338955ad6e43e2" 1057 | dependencies = [ 1058 | "env_logger", 1059 | "lazy_static", 1060 | "log", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "solana-program" 1065 | version = "1.9.29" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "f5deafc4902425d40197f74166640300dd20b078e4ffd518c1bb56ceb7e01680" 1068 | dependencies = [ 1069 | "base64 0.13.0", 1070 | "bincode", 1071 | "bitflags", 1072 | "blake3", 1073 | "borsh", 1074 | "borsh-derive", 1075 | "bs58 0.4.0", 1076 | "bv", 1077 | "bytemuck", 1078 | "console_error_panic_hook", 1079 | "console_log", 1080 | "curve25519-dalek", 1081 | "getrandom 0.1.16", 1082 | "itertools", 1083 | "js-sys", 1084 | "lazy_static", 1085 | "libsecp256k1", 1086 | "log", 1087 | "num-derive", 1088 | "num-traits", 1089 | "parking_lot", 1090 | "rand", 1091 | "rustc_version", 1092 | "rustversion", 1093 | "serde", 1094 | "serde_bytes", 1095 | "serde_derive", 1096 | "sha2", 1097 | "sha3", 1098 | "solana-frozen-abi", 1099 | "solana-frozen-abi-macro", 1100 | "solana-logger", 1101 | "solana-sdk-macro", 1102 | "thiserror", 1103 | "wasm-bindgen", 1104 | ] 1105 | 1106 | [[package]] 1107 | name = "solana-sdk-macro" 1108 | version = "1.9.29" 1109 | source = "registry+https://github.com/rust-lang/crates.io-index" 1110 | checksum = "3db4c93bd43c91290ad54fe6ff86179a859954f196507c4789a4876d38a62f17" 1111 | dependencies = [ 1112 | "bs58 0.4.0", 1113 | "proc-macro2", 1114 | "quote", 1115 | "rustversion", 1116 | "syn", 1117 | ] 1118 | 1119 | [[package]] 1120 | name = "subtle" 1121 | version = "2.4.1" 1122 | source = "registry+https://github.com/rust-lang/crates.io-index" 1123 | checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" 1124 | 1125 | [[package]] 1126 | name = "syn" 1127 | version = "1.0.98" 1128 | source = "registry+https://github.com/rust-lang/crates.io-index" 1129 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 1130 | dependencies = [ 1131 | "proc-macro2", 1132 | "quote", 1133 | "unicode-ident", 1134 | ] 1135 | 1136 | [[package]] 1137 | name = "termcolor" 1138 | version = "1.1.3" 1139 | source = "registry+https://github.com/rust-lang/crates.io-index" 1140 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 1141 | dependencies = [ 1142 | "winapi-util", 1143 | ] 1144 | 1145 | [[package]] 1146 | name = "thiserror" 1147 | version = "1.0.31" 1148 | source = "registry+https://github.com/rust-lang/crates.io-index" 1149 | checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" 1150 | dependencies = [ 1151 | "thiserror-impl", 1152 | ] 1153 | 1154 | [[package]] 1155 | name = "thiserror-impl" 1156 | version = "1.0.31" 1157 | source = "registry+https://github.com/rust-lang/crates.io-index" 1158 | checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" 1159 | dependencies = [ 1160 | "proc-macro2", 1161 | "quote", 1162 | "syn", 1163 | ] 1164 | 1165 | [[package]] 1166 | name = "toml" 1167 | version = "0.5.9" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" 1170 | dependencies = [ 1171 | "serde", 1172 | ] 1173 | 1174 | [[package]] 1175 | name = "typenum" 1176 | version = "1.15.0" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 1179 | 1180 | [[package]] 1181 | name = "unicode-ident" 1182 | version = "1.0.1" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 1185 | 1186 | [[package]] 1187 | name = "unicode-segmentation" 1188 | version = "1.9.0" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" 1191 | 1192 | [[package]] 1193 | name = "version_check" 1194 | version = "0.9.4" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1197 | 1198 | [[package]] 1199 | name = "wasi" 1200 | version = "0.9.0+wasi-snapshot-preview1" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1203 | 1204 | [[package]] 1205 | name = "wasi" 1206 | version = "0.11.0+wasi-snapshot-preview1" 1207 | source = "registry+https://github.com/rust-lang/crates.io-index" 1208 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1209 | 1210 | [[package]] 1211 | name = "wasm-bindgen" 1212 | version = "0.2.81" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" 1215 | dependencies = [ 1216 | "cfg-if", 1217 | "wasm-bindgen-macro", 1218 | ] 1219 | 1220 | [[package]] 1221 | name = "wasm-bindgen-backend" 1222 | version = "0.2.81" 1223 | source = "registry+https://github.com/rust-lang/crates.io-index" 1224 | checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" 1225 | dependencies = [ 1226 | "bumpalo", 1227 | "lazy_static", 1228 | "log", 1229 | "proc-macro2", 1230 | "quote", 1231 | "syn", 1232 | "wasm-bindgen-shared", 1233 | ] 1234 | 1235 | [[package]] 1236 | name = "wasm-bindgen-macro" 1237 | version = "0.2.81" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" 1240 | dependencies = [ 1241 | "quote", 1242 | "wasm-bindgen-macro-support", 1243 | ] 1244 | 1245 | [[package]] 1246 | name = "wasm-bindgen-macro-support" 1247 | version = "0.2.81" 1248 | source = "registry+https://github.com/rust-lang/crates.io-index" 1249 | checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" 1250 | dependencies = [ 1251 | "proc-macro2", 1252 | "quote", 1253 | "syn", 1254 | "wasm-bindgen-backend", 1255 | "wasm-bindgen-shared", 1256 | ] 1257 | 1258 | [[package]] 1259 | name = "wasm-bindgen-shared" 1260 | version = "0.2.81" 1261 | source = "registry+https://github.com/rust-lang/crates.io-index" 1262 | checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" 1263 | 1264 | [[package]] 1265 | name = "web-sys" 1266 | version = "0.3.58" 1267 | source = "registry+https://github.com/rust-lang/crates.io-index" 1268 | checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" 1269 | dependencies = [ 1270 | "js-sys", 1271 | "wasm-bindgen", 1272 | ] 1273 | 1274 | [[package]] 1275 | name = "winapi" 1276 | version = "0.3.9" 1277 | source = "registry+https://github.com/rust-lang/crates.io-index" 1278 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1279 | dependencies = [ 1280 | "winapi-i686-pc-windows-gnu", 1281 | "winapi-x86_64-pc-windows-gnu", 1282 | ] 1283 | 1284 | [[package]] 1285 | name = "winapi-i686-pc-windows-gnu" 1286 | version = "0.4.0" 1287 | source = "registry+https://github.com/rust-lang/crates.io-index" 1288 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1289 | 1290 | [[package]] 1291 | name = "winapi-util" 1292 | version = "0.1.5" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1295 | dependencies = [ 1296 | "winapi", 1297 | ] 1298 | 1299 | [[package]] 1300 | name = "winapi-x86_64-pc-windows-gnu" 1301 | version = "0.4.0" 1302 | source = "registry+https://github.com/rust-lang/crates.io-index" 1303 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1304 | 1305 | [[package]] 1306 | name = "yansi" 1307 | version = "0.5.1" 1308 | source = "registry+https://github.com/rust-lang/crates.io-index" 1309 | checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" 1310 | 1311 | [[package]] 1312 | name = "zeroize" 1313 | version = "1.3.0" 1314 | source = "registry+https://github.com/rust-lang/crates.io-index" 1315 | checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" 1316 | --------------------------------------------------------------------------------