Copy $ git clone git@github.com:solana-labs/dapp-scaffold.git
Copy $ yarn add @dappio-wonderland/navigator
$ yarn add @dappio-wonderland/gateway
$ yarn add @project-serum/anchor@^0.24.2
$ yarn add @solana/web3.js@^1.36.0
Add resolution for @jup-ag/core
Copy // package.json
{
"name": "universal-rabbit-hole-example",
"version": "0.1.0",
"license": "MIT",
"private": false,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@dappio-wonderland/gateway": "^0.2.14",
"@dappio-wonderland/navigator": "^0.2.10",
"@heroicons/react": "^1.0.5",
"@project-serum/anchor": "^0.24.2",
"@solana/wallet-adapter-base": "^0.9.3",
"@solana/wallet-adapter-react": "0.15.18",
"@solana/wallet-adapter-react-ui": "^0.9.5",
"@solana/wallet-adapter-wallets": "^0.15.3",
"@solana/web3.js": "^1.36.0",
"@tailwindcss/typography": "^0.5.0",
"daisyui": "^1.24.3",
"immer": "^9.0.12",
"next": "12.0.8",
"next-compose-plugins": "^2.2.1",
"next-transpile-modules": "^9.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"zustand": "^3.6.9"
},
"devDependencies": {
"@types/node": "17.0.10",
"@types/react": "17.0.38",
"autoprefixer": "^10.4.2",
"eslint": "8.7.0",
"eslint-config-next": "12.0.8",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.15",
"typescript": "4.5.4"
},
"resolutions": {
"@jup-ag/core": "1.0.0-beta.26",
"@solana/wallet-adapter-react": "0.15.18"
}
}
Copy // next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
}
return config;
},
};
module.exports = nextConfig;
Copy $ touch src/utils/anchorWallet.tsx
Copy // src/utils/anchorWallet.tsx
import { PublicKey, Transaction, Keypair } from "@solana/web3.js";
import { WalletContextState } from "@solana/wallet-adapter-react";
export class AnchorWallet {
readonly payer: Keypair;
readonly publicKey: PublicKey;
constructor(readonly wallet: WalletContextState) {
// Never used dummy payer
this.payer = Keypair.generate();
this.publicKey = wallet.publicKey ? wallet.publicKey : PublicKey.default;
}
async signTransaction(tx: Transaction): Promise<Transaction> {
return await this.wallet.signTransaction!(tx);
}
async signAllTransactions(txs: Transaction[]): Promise<Transaction[]> {
return await this.wallet.signAllTransactions!(txs);
}
}