Skip to content

Commit

Permalink
updating rpc endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dabit3 committed Nov 10, 2021
1 parent dc6f716 commit 5da9942
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_WORKSPACE_URL=$CLIENT_URL
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tasks:
command: npx hardhat node
- name: Deploy smart contract and start server
command: |
export CLIENT_URL="$(gp url 8545)"
gp await-port 8545
npx hardhat run scripts/deploy.js --network localhost
npm run dev
Expand Down
7 changes: 6 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ import {
import NFT from '../artifacts/contracts/NFT.sol/NFT.json'
import Market from '../artifacts/contracts/Market.sol/NFTMarket.json'

let rpcEndpoint = null

if (process.env.REACT_APP_WORKSPACE_URL) {
rpcEndpoint = process.env.REACT_APP_WORKSPACE_URL
}
export default function Home() {
const [nfts, setNfts] = useState([])
const [loadingState, setLoadingState] = useState('not-loaded')
useEffect(() => {
loadNFTs()
}, [])
async function loadNFTs() {
const provider = new ethers.providers.JsonRpcProvider()
const provider = new ethers.providers.JsonRpcProvider(rpcEndpoint)
const tokenContract = new ethers.Contract(nftaddress, NFT.abi, provider)
const marketContract = new ethers.Contract(nftmarketaddress, Market.abi, provider)
const data = await marketContract.fetchMarketItems()
Expand Down

0 comments on commit 5da9942

Please sign in to comment.