singularity-client-script v1.7.29
Singularity-client-script
Inject the following script in your index.html
(function (w, d, s, o, f, js, fjs) {
w[o] =
w[o] ||
function () {
(w[o].q = w[o].q || []).push(arguments);
};
(js = d.createElement(s)), (fjs = d.getElementsByTagName(s)[0]);
js.id = o;
js.src = f;
js.async = 1;
fjs.parentNode.insertBefore(js, fjs);
})(window, document, "script", "Singularity", "https://unpkg.com/singularity-client-script@latest/index.js");
There are two ways of communication between client and Singualarity SDK
1. Subscription based
- walletInfo
- drawerOpen
- drawerClose
const handleWalletInfo = (event) => {
const walletDetails = event.detail.callback();
console.log('Wallet details', walletDetails);
};
window.SingularityEvent.subscribe('walletInfo', handleWalletInfo);
const handleDrawerOpen = () => {
console.log('Drawer open');
};
window.SingularityEvent.subscribe('drawerOpen', handleDrawerOpen);
const handleDrawerClose = () => {
console.log('Drawer close');
};
window.SingularityEvent.subscribe('drawerClose', handleDrawerClose);
2. Function based
- close
- open
- getConnectUserInfo
- transactionFlow
- requestPersonalSignature
- requestTypedSignature
logout
window.SingularityEvent.close();
window.SingularityEvent.open();
const data = await window.SingularityEvent.getConnectUserInfo();
window.SingularityEvent.logout();
const signature = await window.SingularityEvent.requestPersonalSignature("hello world")
const domain = {
name: 'GamePay',
version: '1',
chainId: 97,
verifyingContract: '0xED975dB5192aB41713f0080E7306E08188e53E7f'
};
const types = {
bid: [
{ name: 'bidder', type: 'address' },
{ name: 'collectableId', type: 'uint256' },
{ name: 'amount', type: 'uint256' },
{ name: 'nounce', type: 'uint' }
]
};
const values = {
bidder: '0xAa81f641d4b3546F05260F49DEc69Eb0314c47De',
collectableId: 1,
amount: 100,
nounce: 1
};
const primaryType ="bid";
const signature = await window.SingularityEvent.requestTypedSignature(domain, primaryType, types, values)
window.SingularityEvent.collectPayment({name:'INIT_COLLECT_PAYMENT',data:
{
"transactionId": "090cda7e-1a1a-4e86-8303-916e56d99269",
"clientReferenceId": "1005",
"singularityTransactionStatus": "SINGULARITY_TRANSACTION_INITIATED",
"clientId": "15de55a2-c0a7-420d-97a7-1d907c61ba71",
"userId": "816acdff-a636-4bec-af27-66f073305537",
"primaryWalletDetails": {
"chainId": "80001",
"chainCategory": "EVM",
"walletAddress": "0xa9cfB6D7AdFbf5ff9F5A05a78c546547754D3aF3"
},
"clientRequestedAsset": {
"assetId": "66",
"chainId": "80001",
"chainName": "MUMBAI",
"chainCategory": "EVM",
"chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
"currencyType": "USDC",
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/usdc.svg"
},
"paymentOptions": {
"crypto": [
{
"assetId": "55",
"chainId": "80001",
"chainName": "MUMBAI",
"chainCategory": "EVM",
"currencyType": "MATIC",
"chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
"decimal": 18,
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg",
"collectCurrencyAmount": "0.77",
"collectCurrencyAmountInUSD": "0.654654",
"collectGasInformation": {
"collectGasAmount": "3.1500000315E-5",
"collectGasAmountInUSD": "2.6775000267749998E-5",
"currencyType": "MATIC",
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg"
},
"selected": false,
"userBalanceDetails": []
},
{
"assetId": "66",
"chainId": "80001",
"chainName": "MUMBAI",
"chainCategory": "EVM",
"currencyType": "USDC",
"chainIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/chain/mumbai.svg",
"decimal": 6,
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/usdc.svg",
"collectCurrencyAmount": "1.0",
"collectCurrencyAmountInUSD": "1.0",
"collectGasInformation": {
"collectGasAmount": "3.1500000315E-5",
"collectGasAmountInUSD": "2.6781300267812997E-5",
"currencyType": "MATIC",
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/matic.svg"
},
"selected": false,
"userBalanceDetails": [
{
"userAddress": "0xa9cfB6D7AdFbf5ff9F5A05a78c546547754D3aF3",
"userBalance": "1.0E-11",
"userBalanceInUSD": "1.0E-11"
}
]
}
],
"fiat": {
"paymentMode": {
"credit_card": [
{
"provider": "wert",
"collectCurrencyAmountInUSD": 1.89,
"selected": false,
"currencyIconURL": "https://singularity-icon-assets.s3.ap-south-1.amazonaws.com/currency/creditcard.svg",
"data": {
"signedData": {
"address": "0x2a7ac99a7cE7777dD4598e8eb898862a2440fe51",
"commodity": "MATIC:mumbai",
"commodity_amount": "2",
"pk_id": "key1",
"sc_address": "0x43b40335Fe283502Aaf08c810e4772cbd4b8107D",
"sc_id": "fc8d6225-fdf8-4cfc-a76f-10fdd84325fd",
"sc_input_data": "0x23c08d420000000000000000000000002a7ac99a7ce7777dd4598e8eb898862a2440fe5100000000000000000000000017f547ae02a94a0339c4cfe034102423907c45920000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000033132330000000000000000000000000000000000000000000000000000000000",
"signature": "905A959AA6CA1E9F6F5ECE18A94021873CBC44C9559CB4CF0E4183AF275C570B3DB77D0915CF240719FA22B0939E08ED8A9AF4964F3ADB65A5B1A9DBE9B08E0E"
},
"commodity": "MATIC:mumbai",
"partnerId": "01GH9K0D7HF976CMVX233RGV9E"
}
}
]
}
}
},
"clientRequestedAssetQuantity": "1",
"userSelectedAsset": null,
"userSelectedAssetQuantity": null,
"singularityTransactionType": "RECEIVE",
"singularityTransactionSubType": null,
"singularityTransactionExchangeMode": null,
"singularityExchangePricesAndBalanceDetailsList": null,
"status": "SUCCESS",
"error": null
}
});
15 days ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
11 months ago
11 months ago
8 months ago
8 months ago
11 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago