Created
June 28, 2022 08:03
-
-
Save arcticfloyd1984/f21bf7cf2451f614f000117b27a49bf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authToken = '8ee71107-5ce2-4eba-8978-fe51df4bdce2'; | |
const apiKey = 'sCd7Ht3sK.e21885c4-5f31-469a-8e15-969e47ec7842'; | |
const contractAddress = '0x6e56b609E167c79C6C21b356802b3C831E13BF1c'; | |
const fetch = require("node-fetch"); | |
const abi = JSON.stringify([ | |
{ | |
"inputs": [ | |
{ | |
"internalType": "string", | |
"name": "name", | |
"type": "string" | |
}, | |
{ | |
"internalType": "string", | |
"name": "symbol", | |
"type": "string" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "totalSupply", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Approval", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": false, | |
"internalType": "address", | |
"name": "userAddress", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "address payable", | |
"name": "relayerAddress", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "bytes", | |
"name": "functionSignature", | |
"type": "bytes" | |
} | |
], | |
"name": "MetaTransactionExecuted", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "to", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "uint256", | |
"name": "value", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "userAddress", | |
"type": "address" | |
}, | |
{ | |
"internalType": "bytes", | |
"name": "functionSignature", | |
"type": "bytes" | |
}, | |
{ | |
"internalType": "bytes32", | |
"name": "sigR", | |
"type": "bytes32" | |
}, | |
{ | |
"internalType": "bytes32", | |
"name": "sigS", | |
"type": "bytes32" | |
}, | |
{ | |
"internalType": "uint8", | |
"name": "sigV", | |
"type": "uint8" | |
} | |
], | |
"name": "executeMetaTransaction", | |
"outputs": [ | |
{ | |
"internalType": "bytes", | |
"name": "", | |
"type": "bytes" | |
} | |
], | |
"stateMutability": "payable", | |
"type": "function", | |
"payable": true | |
}, | |
{ | |
"inputs": [], | |
"name": "getChainID", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "pure", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "user", | |
"type": "address" | |
} | |
], | |
"name": "getNonce", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "nonce", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "nonce", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "chainID", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "bytes", | |
"name": "functionSignature", | |
"type": "bytes" | |
}, | |
{ | |
"internalType": "bytes32", | |
"name": "sigR", | |
"type": "bytes32" | |
}, | |
{ | |
"internalType": "bytes32", | |
"name": "sigS", | |
"type": "bytes32" | |
}, | |
{ | |
"internalType": "uint8", | |
"name": "sigV", | |
"type": "uint8" | |
} | |
], | |
"name": "verify", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [], | |
"name": "name", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [], | |
"name": "symbol", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [], | |
"name": "decimals", | |
"outputs": [ | |
{ | |
"internalType": "uint8", | |
"name": "", | |
"type": "uint8" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "account", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "recipient", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "transfer", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "owner", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
} | |
], | |
"name": "allowance", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function", | |
"constant": true | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "approve", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "sender", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "recipient", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "transferFrom", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "addedValue", | |
"type": "uint256" | |
} | |
], | |
"name": "increaseAllowance", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "spender", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "subtractedValue", | |
"type": "uint256" | |
} | |
], | |
"name": "decreaseAllowance", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "account", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "amount", | |
"type": "uint256" | |
} | |
], | |
"name": "mint", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
} | |
]) | |
const addContract = () => { | |
const url = "https://api.biconomy.io/api/v1/smart-contract/public-api/addContract"; | |
var formData = new URLSearchParams({ | |
"contractName" : "Gasless Token", | |
"contractAddress" : contractAddress, | |
"abi" : abi, | |
"contractType" : "SC", | |
"metaTransactionType": "DEFAULT" | |
}); | |
const requestOptions = { | |
method: 'POST', | |
headers: { "Content-Type": "application/x-www-form-urlencoded", "authToken": authToken, "apiKey" : apiKey }, | |
body: formData | |
}; | |
fetch(url, requestOptions) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); | |
} | |
const deleteContract = () => { | |
const url = "https://api.biconomy.io/api/v1/smart-contract/public-api/deleteContract"; | |
var formData = new URLSearchParams({ | |
"contractAddress" : contractAddress, | |
"contractType" : "SC", | |
}); | |
const requestOptions = { | |
method: 'DELETE', | |
headers: { "Content-Type": "application/x-www-form-urlencoded", "authToken": authToken, "apiKey" : apiKey }, | |
body: formData | |
}; | |
fetch(url, requestOptions) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); | |
} | |
const addMethod = () => { | |
const url = "https://api.biconomy.io/api/v1/meta-api/public-api/addMethod"; | |
let formData = new URLSearchParams({ | |
"apiType" : "native", | |
"methodType" : "write", | |
"name": "executeMeta", | |
"contractAddress" : contractAddress, | |
"method" : "executeMetaTransaction" | |
}) | |
const requestOptions = { | |
method: 'POST', | |
headers: { "Content-Type": "application/x-www-form-urlencoded", "authToken": authToken, "apiKey" : apiKey }, | |
body: formData | |
}; | |
fetch(url, requestOptions) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); | |
} | |
const deleteMethod = () => { | |
const url = "https://api.biconomy.io/api/v1/meta-api/public-api/deleteMethod"; | |
let formData = new URLSearchParams({ | |
"contractAddress" : contractAddress, | |
"method" : "executeMetaTransaction" | |
}) | |
const requestOptions = { | |
method: 'DELETE', | |
headers: { "Content-Type": "application/x-www-form-urlencoded", "authToken": authToken, "apiKey" : apiKey }, | |
body: formData | |
}; | |
fetch(url, requestOptions) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); | |
} | |
const addDapp = () => { | |
const url = "http://localhost:4000/api/v1/dapp/public-api/create-dapp"; | |
let formData = new URLSearchParams({ | |
"dappName" : "dapp-test-3", | |
"networkId" : "42", | |
"enableBiconomyWallet": false | |
}) | |
const requestOptions = { | |
method: 'POST', | |
headers: { "Content-Type": "application/x-www-form-urlencoded", "authToken": '178e665d-8f9d-43fd-9762-e0fc15be7b8e' }, | |
body: formData | |
}; | |
fetch(url, requestOptions) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); | |
} | |
addContract(); | |
// deleteContract(); | |
// addMethod(); | |
// deleteMethod(); | |
// addDapp(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment