Integrate using vanilla JS

Useful links:


Simple example

Allow user to choose amount, asset and wallet address inside widget

<script src="https://cdn.jsdelivr.net/npm/@ramp-network/ramp-instant-sdk/dist/ramp-instant-sdk.umd.min.js"></script>
<script>
  function buy() {
    new rampInstantSdk.RampInstantSDK({
      hostAppName: "Your App Name",
      hostLogoUrl: "https://your.logo/url.png",
      variant: "auto",
    }).show();
  }
</script>
<section>
  <h4>Buy with Ramp Instant</h4>
  <button type="button" onclick="buy()">Buy</button>
</section>

Advanced example

Integrate asset and amount form into your app. The user will not be able to change those inside widget.

<script src="https://cdn.jsdelivr.net/npm/@ramp-network/ramp-instant-sdk/dist/ramp-instant-sdk.umd.min.js"></script>
<script>
  function buy() {
    let data = Array.from(document.forms["ramp-instant-form"]).reduce(
      (acc, cur) => {
        acc[cur.id] = cur.value;
        return acc;
      },
      {}
    );
    let widget = new rampInstantSdk.RampInstantSDK({
      hostAppName: "Your App Name",
      hostLogoUrl: "https://your.logo/url.png",
      variant: "auto",
      swapAmount: parseFloat(data["ramp-instant-amount"]) * 10 ** 18,
      swapAsset: data["ramp-instant-asset"],
    });
    widget.domNodes.overlay.style.zIndex = 1000;
    widget.on("*", (event) => console.log(event));
    widget.show();
  }
</script>
<section>
  <h4>Buy with Ramp Instant</h4>
  <form id="ramp-instant-form" class="ramp-instant-form">
    <div>
      <input id="ramp-instant-amount" type="number" step="0.01" value="10" />
      <select id="ramp-instant-asset">
        <option value="ETH">ETH</option>
        <option value="DAI" selected>DAI</option>
      </select>
    </div>
    <button type="button" onclick="buy()">
      Buy
    </button>
  </form>
</section>