javascriptsolana-web3js

How to connect phantom wallet by Solana Pay using Web3.js?


I am trying connect Phantom wallet from Solana Pay using Web3.js However I am constantly getting the error "Buffer is not defined". How to resolve this?

Note: I am not using Nodejs. I am trying to create the integration with the Web3.js library.

Here is the code:

<script>
// The below is the code where I am getting the error



                    var transaction= new solanaWeb3.Transaction().add(
                        
                    );

</script>

Solution

  • Use solana/web3.js v1.30.2

    Or install some extra dependencies for the latest version

    I'm sharing a blog. It's based on ReactJS but hope you can understand. And no issue, change your version to 1.30.2, and it will work fine.

    Blog_for_extra_dependencies

    You can refer to this code also. CodeSandbox