Skip to content
Last updated

Here you will find a simple JS implementation of the SDK.

!function(callback){
var b=document.createElement('script'); b.type="text/javascript", b.async=!0,
b.src="https://sdk.banxa.com/js/banxa-sdk-latest.js";
var x=document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(b,x);
if(callback){b.addEventListener("load",function(){callback()})}}
(yourOnLoadFunction);

Initiate Banxa class

Use the following snippet to create an instance of the banxa class to generate redirect and iframes.

<script>
    const banxa = new Banxa();
    const banxaWithPartner = new Banxa(`your-partner-name`);
</script>

iFrame

Use the following snippet to create an iframe:

<script>
    banxa.iframe('#iframe', '#iframeTarget',
        {
             'fiatType': 'AUD',
             'coinType': 'BTC',
          'walletAddre  "400px"
               'fiatAmount': 200,
                'coinAmount': 0.5,
    },
        "800px",
      ss': '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb',
    );
</script>

<button id="iframeButton">Launch iframe</button>

<div id="iframeTarget">
    <!-- Where the iframe will be loaded  
-->
</div>

Redirect

Use the following snippet to create a redirect to the Banxa Order page:

<script>
    banxa.redirect('#redirect',
            {
                'fiatType': 'AUD',
                'coinType': 'BTC',
                'fiatAmount': 500,
                'coinAmount': 0.2,
                'walletAddress': '3Hiy7HuFcqwkgERyfRSwEHqrwSwTirm8zb',
            });
</script>

<button id="redirect">Launch Redirect</button>

Parameters

The follow parameters can be passed:

URL ParameterDescription
fiatTypeFiat currency code that the customer wants to exchange e.g USD
fiatAmountFiat amount that the customer wants to exchange e.g. 500. If both a fiatAmount and coinAmount are passed, then the fiatAmount will be used
coinTypeCoin currency code that the customer wants to exchange e.g. ETH
coinAmountCoin amount that the customer wants to exchange e.g. 800. If both a fiatAmount and coinAmount are passed, then the fiatAmount will be used
blockchainBlockchain network code that is selected by the customer. If this parameter is not passed, the default blockchain configured for the coinType selected will apply
walletAddressCustomer's wallet address
walletAddressTagCustomer's wallet tag or memo. This is required for transacting on certain blockchains such as BNB and XR
codeOnly required if you implement an iFrame approach. Your unique iFrame code that Banxa has issued you with. This will return HTML that can be embedded into your site
sellModeIndicates whether the customer wants to sell. The customer will be shown the Sell Order Form when they are redirected to the Banxa cart. This will depend on whether you have implemented the option to sell. If this parameter is not passed, then the order will default to buyMode