3

I have a situation where a set of two contracts is deployed to two addresses, for example:

share.ysn-1_0_0.ysn.testnet
market.share.ysn-1_0_0.ysn.testnet

In this case, share is an NFT contract while market is an open bids system plugged into it. Different projects are deployed under ysn.testnet with the same pattern, and an FT contract is deployed at ysn-1_0_0.ysn.testnet.

I'm trying to figure out the best way to handle this from one front-end without too many redirects, preferably one. A thing that came to mind is to have a proxy contract that distributes the Promise requests to the set of contracts above; is that feasible, or might it have drawbacks?

6
  • you're talking about the redirects from NEAR Wallet when the user authorizes the 2 contracts? Commented Jul 19, 2021 at 16:33
  • Yes, @BenTheHumanMan, if you have multiple contracts under the same front-end, if you try to call a contract method that reads or updates the state and targets multiple addresses, you end up with as many redirects as the number of contracts. Commented Jul 19, 2021 at 17:00
  • One method will target multiple contracts and it doesn't throw gas panics? Without knowing more about your setup, I would guess that it's a design issue. Users should only need to authorize the bidding contract then subsequent bids they make that would withdraw funds - berryclub.io Commented Jul 19, 2021 at 17:11
  • 1
    I'm refactoring the front-end to handle multiple nft projects (each with their market) and, for example, if you want to build a feed that pulls tokens from all of the nft contracts (without having a back-end) you would be redirected. Thanks for the support; I'll do some more reading tomorrow and see if it's a design issue on my side. Commented Jul 19, 2021 at 17:24
  • 1
    I wish I could be better help. Please post here once you find a solution. I would think the ft/nft contract calls could maybe just be proxied by the market contract so the user wallet only needs to authorize market which would call/sign the various nft/ft contracts calls. Commented Jul 19, 2021 at 17:58

1 Answer 1

1

My solution ended up using localStorage to save contractAddress on sign in and sign out and having:

useEffect(switchProject, [router.asPath])

to sign out if the path is for a different project than the one signed in for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.