functiongetProvider(){const provider =window.foxwallet&&window.foxwallet.aleo;if(!provider){window.open("https://foxwallet.com/download");throw`Please guide users to download from FoxWallet official website`;}return provider;}
try{const provider =getProvider();// type Record = {// id: string;// owner: string;// program_id: string;// spent: boolean;// data: string;// recordName: string;// }const records =await provider.requestRecords("credits.aleo");console.log("requestRecords ", records);}catch(e){console.log('requestRecords failed');}
requestRecordPlaintexts
请求带有 Connect 子账户的解密明文的记录
try{const provider =getProvider();// type Record = {// id: string;// owner: string;// program_id: string;// spent: boolean;// data: string;// recordName: string;// plaintext: string;// }const records =await provider.requestRecordPlaintexts("credits.aleo");console.log("requestRecordPlaintexts ", records);}catch(e){console.log('requestRecordPlaintexts failed');}
请求事务
请求 Connect 子账户发送交易
try{const provider =getProvider();const result =await provider.requestTransaction({address:""/* connected address */,chainId:"testnetbeta",transitions:[{program:"credits.aleo",functionName:"transfer_public",inputs:[""/* transfer address */,"1000000u64"]}];fee:5555/* estimate fee */,feePrivate:false,});console.log("requestTransaction ", result);}catch(e){console.log('requestTransaction failed');}
transactionStatus
请求上一次发送的交易的状态
try{const provider =getProvider();const result =await provider.transactionStatus(""/* transaction id */);// type Status = "Queued" | "Generating Prover Files" | "Generating Transaction" | "Broadcasting" | "Completed" | "Rejected" | "Finalized" | "Failed"console.log("transactionStatus ", result);}catch(e){console.log('transactionStatus failed');}
请求部署
请求部署
try{const provider =getProvider();const result =await provider.requestDeploy({address:""/* connected address */,chainId:"testnetbeta",program:""/* the program content to be deployed */,fee:2000000/* estimate fee */;feePrivate:false;});console.log("requestDeploy ", result);}catch(e){console.log('requestDeploy failed');}
importReact,{FC, useMemo }from"react";import{WalletProvider}from"@demox-labs/aleo-wallet-adapter-react";import{WalletModalProvider}from"@demox-labs/aleo-wallet-adapter-reactui";import{LeoWalletAdapter}from"@demox-labs/aleo-wallet-adapter-leo";import{FoxWalletAdapter}from"@foxwallet/aleo-wallet-adapter-fox";import{DecryptPermission,WalletAdapterNetwork,}from"@demox-labs/aleo-wallet-adapter-base";// Default styles that can be overridden by your apprequire("@demox-labs/aleo-wallet-adapter-reactui/styles.css");exportconstWallet:FC=()=>{const wallets =useMemo(()=>[newLeoWalletAdapter({ appName:"Leo Demo App",}),newFoxWalletAdapter({}),],[]);return(<WalletProviderwallets={wallets}decryptPermission={DecryptPermission.UponRequest}network={WalletAdapterNetwork.Localnet}autoConnect><WalletModalProvider> // Your app's components go here</WalletModalProvider></WalletProvider>);};
Q: “error while loading shared libraries: libnvrtc.so.12: cannot open shared object file: No such file or directory” 这个报错是什么问题? A: 这代表着 CUDA 安装问题,请检查 CUDA 是否正确安装。