Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interact with multiple contracts

Tags:

nearprotocol

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?

like image 623
Crazy Barney Avatar asked Mar 22 '26 04:03

Crazy Barney


1 Answers

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.

like image 166
Crazy Barney Avatar answered Mar 24 '26 23:03

Crazy Barney



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!