Created
May 27, 2024 12:49
-
-
Save coffiasd/eb3df6a2e94fc1b3aab30f407e114904 to your computer and use it in GitHub Desktop.
verify contract
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
export default async function handler(req, res) { | |
if (req.method !== 'POST') { | |
return; | |
} | |
const dd = req.body | |
let contractname; | |
let data = new FormData(); | |
let API_KEY = 'xxxxxxxx'; | |
let API_URL = 'https://api.etherscan.io/api'; | |
data.append('sourceCode', JSON.stringify(ALL)); | |
data.append('module', 'contract'); | |
data.append('action', 'verifysourcecode'); | |
data.append('apikey', API_KEY); | |
data.append('chainId', dd.chain); | |
data.append('codeformat', 'solidity-standard-json-input'); | |
data.append('contractaddress', dd.contract); | |
data.append('contractname', contractname); | |
data.append('compilerversion', 'v0.8.24+commit.e11b9ed9'); | |
data.append('constructorArguments', dd.args.substring(2)); | |
let config = { | |
method: 'post', | |
maxBodyLength: Infinity, | |
url: API_URL, | |
headers: { | |
...data.getHeaders() | |
}, | |
data: data | |
}; | |
axios.request(config) | |
.then((response) => { | |
console.log(JSON.stringify(response.data)); | |
}) | |
.catch((error) => { | |
console.log(error); | |
}); | |
res.status(200).json({ data: ''}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment