I know there are many looking to create DApps on Wix using Web3 or Ethereum, I have also been looking into this for a number of months, at present for some reason I am unable to get a website to interact with Metamask however you can engage with the Ethereum Blockchain via Ethers.
I provide the basic page code to get you started, the rest is in the Ethers.js Docs. This I hope will help those who have been trying to do something like this for some time.
Hi, Yes I have, I have a wallet working that I have built using ethers. It may have failed if you have not included ethers.js in the backend, the code should also be placed in a .jsw module.
@sonicswapstu you need to have dev mode switched to on, it will enable you to create JSW modules. I will upload some of the code I have to help you out a bit shortly.
@sonicswapstu you need to have dev mode switched to on, it will enable you to create JSW modules. I will upload some of the code I have to help you out a bit shortly.
you have to import the web3 module to interact and connect with Metamask. It should work the same as most other implementations you can find online. Here is a simple example.
essentially with this code all we are doing is checking if window.ethereum exists. If so we create a new web3 object and send a request to initiate a popup dialogue box. The await window.ethereum.request method is what renders the dialogue box and prompts the user to connect.
Thanks. I already have my working code for my payment app Iām building, currently using ethers.js, all good.
Itās the importing ethers into Wix I need to do for someoneās site, Iāll revisit the docs to try find how they make a JSW module and include it - unless you can share that specific info?
Once included I can get to work on wixifying my current code as required
Iāve already built past this part, thanks though. Itās integration into Wix that Iām specifically looking for, but as Simon points out its its a matter of creating a module to get the 3rd party libraries in first.
Assuming you have developer mode4 enabled here is how you access and create the JSW files. After creating an export function in the JSW file you will just import it in brackets into whatever page you want to call it in. (usually the home page). Hope this helps.
@amotor very true but then you are having to use a custom element or html box as I believe thatās the only way to get web3 working as wix doesnāt allow access to the window element? or it didnāt, ethers.js is to me a simpler way of implementing a wallet that you can build and make look how you want.
@amotor I upgraded to a premium plan, not just for the custom elements but it would require some engineering to get web3 to work I think, with ethers.js you can build your own version of a ethereum wallet, but can also now use BSC as well as there is an ancillary package @ethers-ancillary/bsc
At the moment the user is having to manually send tokens, and put their TX hash into the form, so I have built a ethers.js payment system that I want to integrateā¦
I expected to be able to (on bookings form page) access the current booking in progress, so I could get itās price value and pass that to my script - where the user will make the payment, it triggers metamask etc) and then complete the booking.
But, it seems there is no way to access any of the data for the booking the user is currently making? Do you know of any way to access this? Or even the service that the user selected so I could use the Wix Ali to even look up the price for the slot on the selected serviceā¦ Possible?
Iāve read the Api docs top to bottom and cannot for the life of me see how to access the currently selected booking/service.
Other option is I rebuild the entire booking process using the APIsā¦! Which is obviously a lot more work, but will if I have to. Seems crazy to do that when all I need is the price of the currently selected service!
Seems it cut the start of my question off. The client has used the built in bookings app to make the bookings pages, so there is a list of services, the calendar where user chooses a slot, and the confirmation page.
I need access to the service (price of it) of the currently selected service.
@simonadams yes Iāve read all the docs and actively using them now but still I have issues.
The site currently uses the booking system. I have since rebuilt the services list using the Wix API, so I can access the prices and service IDs. I need these so I can pass the price to metamask to make the transaction. All good so far.
But, the booking process uses a calendar (scheduled slots) and a final form - which I need to populate a field - bit you canāt when using the booking system.
So my plan now is basically to rebuild the whole calendar/slot chooser and form using the API and my own fields. It feels very over the top, just to get a crypto transaction in between it all!