ポップアップ/Iframe の外観カスタマイズ
dApp のブランドに合わせたポップアップ/iframe の外観カスタマイズ方法
使用例
// Define the default wallet URL for the INTMAX wallet or alternative wallet const DEFAULT_WALLET_URL = "https://wallet.intmax.io"; // Define the path to your preferred icon, assuming the logo.png is in the public folder const DEFAULT_DAPP_ICON = `${window.location.origin}/logo.png`; const DAPP_METADATA = { name: "My Custom DApp", // Use your brand/project name here description: "This dApp allows users to interact with our custom smart contract.", // Use an appropriate description here icons: [DEFAULT_DAPP_ICON], // Use the defined icon path to your icon or logo here };// Function to create an SDK instance, taking the wallet URL as an argument const createsSDK = (walletUrl: string) => { return intmaxDappClient({ wallet: { url: walletUrl, name: "Custom Wallet", // Name of wallet window: { mode: "popup" }, // Choose between 'iframe' or 'popup' }, metadata: DAPP_METADATA, // Pass the DApp metadata providers: { eip155: ethereumProvider() }, // Define the Ethereum provider }); }; const sdk = createsSDK(DEFAULT_WALLET_URL);const Voting = () => { const [accounts, setAccounts] = useState<string[]>([]); const handleConnect = async () => { const intmaxWalletProvider = sdk.provider("eip155:137"); // 137 is Polygon mainnet network, change to network of choice await intmaxWalletProvider.request({ method: "eth_requestAccounts", params: [] }); const accounts = (await intmaxWalletProvider.request({ method: "eth_accounts", params: [] })) as string[]; setAccounts(accounts); }; return ( <div> <button onClick={handleConnect}> {accounts.length > 0 ? `Connected: ${accounts[0]}` : 'Connect Wallet'} </button> </div> ); };
重要事項
最終更新