Description
I was trying to use the defender-sdk along with hardhat-ethers, I manually created the relayer through the openzepplin website and got my relayerApiKey and relayerApiSecret. Then I tried to deploy the smart contract using relayer as signer. but I get issues with the following two lines of code
const provider = client.relaySigner.getProvider();
const signer = client.relaySigner.getSigner(provider, { speed: 'safeLow' });
and then the following error occurs
Error: Network error
at /home/biohazard/finalgo/node_modules/amazon-cognito-identity-js/lib/Client.js:113:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'NetworkError'
}
Code to reproduce
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract abc{
uint public a;
function inc() public {
a++;
}
}
require('dotenv').config();
const {ethers} = require("hardhat");
const {Defender} = require("@openzeppelin/defender-sdk");
async function main(){
const creds = {
relayerApiKey: process.env.RELAYER_API_KEY,
relayerApiSecret: process.env.RELAYER_API_SECRET,
};
const client = new Defender(creds);
const provider = client.relaySigner.getProvider();
const signer = client.relaySigner.getSigner(provider, { speed: 'safeLow' });
const cf = await ethers.getContractFactory("abc",signer)
const ca =await cf.deploy();
console.log(await ca.getAddress());
}
main();
script execution command: npx hardhat run ./file.js --network amoy
error message :
/home/biohazard/finalgo/node_modules/amazon-cognito-identity-js/lib/Client.js:113
throw new Error('Network error');
^
Error: Network error
at /home/biohazard/finalgo/node_modules/amazon-cognito-identity-js/lib/Client.js:113:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'NetworkError'
}
Environment
Hardhat
require('dotenv').config()
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ethers");
require("@nomicfoundation/hardhat-chai-matchers");
require("@nomicfoundation/hardhat-verify");
require('@openzeppelin/hardhat-upgrades');
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: "amoy",
networks: {
amoy: {
url: prcoess.env.rpc_url,
accounts: [process.env.account1, process.env.account2]
}
},
solidity: {
version: "0.8.24",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
};