moralis를 연결하는 방법
https://docs.moralis.io/moralis-dapp/connect-the-sdk
react를 이용할수도 있고, node js를 이용할수도 있고 , 바닐라 js를 이용할수도 있다.
.
.
react를 이용하는 경우
<MoralisProvider serverUrl=“https://xxxxx/server” appId=“YOUR_APP_ID”>11 <App />
</MoralisProvider>
와 같은 형태이다. 이렇게 감싸고 나면 자동으로 initialize된다고 한다. 그러나 왜그런지 모르지만 Moralis.provider에 접근하면 null 이다. 또 enable web3를 해주면 provider가 생성되나 quickswap sdk (https://docs.quickswap.exchange/reference/SDK/07-fetcher)과 같이 사용하려 했으나 되지 않았다.
이상하게도 https://docs.moralis.io/moralis-dapp/web3/web3 에서와 같이 Web3(provider) 에 사용하니 되었다. 아마도 quickswap sdk과만 같이 사용이 되지 않았다.
Moralis 를 enableweb3하려는 경우 https://docs.moralis.io/moralis-dapp/web3/web3 의 await Moralis.enableWeb3(); 방법으로는 되지 않았다. https://github.com/MoralisWeb3/react-moralis#enable-web3-via-metamask 에 있는 const { web3, enableWeb3, isWeb3Enabled, isWeb3EnableLoading, web3EnableError } = useMoralis() 방법으로 사용가능했다.
.
.
https://docs.moralis.io/introduction/readme
moralis는
Moralis api를 통해 스마트 컨트랙트에 접근해 작업 할수도 있고 (주로 native를 사용하면된다)

Moralis provider를 통해 web3.js를 통해 스마트 컨트랙트에 접근할수도 있다.

.
.
moralis에서 스마트 컨트랙트에 접근 작업하는 경우
– https://docs.moralis.io/moralis-dapp/web3-api/native#runcontractfunction
web3 api native의 runContractFunction 를 이용한 방법
– https://docs.moralis.io/moralis-dapp/web3/web3#read-only-functions
web3 provider의 executeFunction 를 이용한 방법
– https://github.com/MoralisWeb3/react-moralis#useweb3executefunction
web3 api의 useWeb3ExecuteFunction을 이용한 방법이 있다.
– https://github.com/MoralisWeb3/react-moralis#usemoralisweb3api
useMoralisWeb3Api
useMoralisWeb3ApiCall 을 이용한 방법 (이 방법 사용해 보았음 잘 작동함)