0

我可以使用“@walletconnect/react-native-dapp”:“^1.6.6”将我的裸 react-native dapp 连接到 alfjores 移动钱包。

用 WalletConnectProvider 将我的 App() 包装在 App.js 中,它使用React-context

export default withWalletConnect(App, {
  redirectUrl:
    Platform.OS === 'web' ? window.location.origin : 'app://WalletHomeScreen',
  storageOptions: {
    asyncStorage: AsyncStorage,
  },
  rpc: {
    44787: "https://alfajores-forno.celo-testnet.org",
    42220: "https://forno.celo.org",
  },
})

然后我使用 useWalletConnect() 挂钩运行 .connect() 和 .killsession() 以使用深度链接进行登录/注销。

import { useWalletConnect } from '@walletconnect/react-native-dapp';
const connector = useWalletConnect();
I used it as:
connector.connect()     [function]
connector.killSession() [function]
connector.connected     [bool]
connector.accounts[0]   [string]

对 alfajores-forno 的读取调用是成功的,但是写入(状态更改)事务是我的确切问题。

我想我无法向 web3 或套件提供 walletconnect 数据。

我几乎尝试了文档中的所有内容:walletconnect celo walletconnect-celo 等等......

我正在使用或使用的代码:

//ABI are from the Factory.sol and Project.sol smart contract deployed on alfajores.
import { Factory_ABI, Project_ABI } from "../ABI";

import {projectContractBytecode} from "../bytecode";
import Web3 from 'web3';
import { newKitFromWeb3 } from '@celo/contractkit';


const contractAddress = "0x0f9Dd41f1c1b1b72808f791A83518dDF0c1aC17f";
const web3 = new Web3("https://alfajores-forno.celo-testnet.org");
const kit = newKitFromWeb3(web3);
const FactoryContract = new kit.connection.web3.eth.Contract(Factory_ABI, contractAddress);

//read-successful.
const projectList = await FactoryContract.methods.getAllDeployedProjects().call();


//write-errors.
const txo = await FactoryContract.methods.createProject(name, symbol, initialSupply);
const data = txo.encodeABI();

const tx = await kit.connection.sendTransactionObject({txo, from: connector.accounts[0]})
OR
const tx = await kit.connection.sendTransactionObject(txo, {from: 0xe2c7618d0f07578cad8de5c05d5cbc3382b04fcd});

and some pnc.

我尝试在 web3 中使用连接器,如下所示:


const connector = useWalletConnect();
const web3 = new Web3(connector);

但这似乎也不起作用。

4

0 回答 0