Transak Docs
Search…
β˜•
JavaScript
The quickest way to get started is to use the JavaScript browser SDK:
1
<!DOCTYPE html>
2
<html>
3
​
4
<head>
5
<meta charset="utf-8" />
6
<script src="<https://global.transak.com/sdk/v1.1/widget.js>" async></script>
7
</head>
8
​
9
<body>
10
<script>
11
function launchTransak() {
12
let transak = new TransakSDK.default({
13
apiKey: '[YOUR_API_KEY]', // Your API Key
14
environment: '[ENVIRONMENT]', // STAGING/PRODUCTION
15
hostURL: window.location.origin,
16
widgetHeight: '625px',
17
widgetWidth: '500px',
18
// Examples of some of the customization parameters you can pass
19
defaultCryptoCurrency: '[DEFAULT_CRYPTO]', // Example 'ETH'
20
walletAddress: '', // Your customer's wallet address
21
themeColor: '[COLOR_HEX]', // App theme color
22
fiatCurrency: '', // If you want to limit fiat selection eg 'USD'
23
email: '', // Your customer's email address
24
redirectURL: ''
25
});
26
transak.init();
27
// To get all the events
28
transak
29
.on(transak.ALL_EVENTS, (data) => {
30
console.log(data)
31
});
32
// This will trigger when the user marks payment is made.
33
transak.on(transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, (orderData) => {
34
console.log(orderData);
35
//transak.close();
36
});
37
}
38
window.onload = function() {
39
launchTransak()
40
}
41
</script>
42
</body>
43
​
44
</html>
Copied!
Copy link