-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
285 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const useLedger = parsedData.useLedger; | ||
const derivationPath = parsedData.derivationPath; | ||
const providerName = parsedData.providerName; | ||
const gasPriceInGwei = parsedData.gasPriceInGwei; | ||
|
||
let networkURL = parsedData.networkURL; | ||
if (providerName === "polygon") { | ||
if (!process.env.ALCHEMY_API_KEY_MATIC) { | ||
console.log("set ALCHEMY_API_KEY_MATIC env variable"); | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MATIC; | ||
} else if (providerName === "polygonMumbai") { | ||
if (!process.env.ALCHEMY_API_KEY_MUMBAI) { | ||
console.log("set ALCHEMY_API_KEY_MUMBAI env variable"); | ||
return; | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MUMBAI; | ||
} | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(networkURL); | ||
const signers = await ethers.getSigners(); | ||
|
||
let EOA; | ||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Transaction signing and execution | ||
console.log("4. EOA to deploy Karma"); | ||
console.log("You are signing the following transaction: Karma.connect(EOA).deploy()"); | ||
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); | ||
Karma = await ethers.getContractFactory("AgentFactorySubscription"); | ||
const karma = await Karma.connect(EOA).deploy({ gasPrice }); | ||
const result = await karma.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: Karma"); | ||
console.log("Contract address:", karma.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// Wait for half a minute for the transaction completion | ||
await new Promise(r => setTimeout(r, 30000)); | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.karmaAddress = karma.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --network " + providerName + " " + karma.address, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const useLedger = parsedData.useLedger; | ||
const derivationPath = parsedData.derivationPath; | ||
const providerName = parsedData.providerName; | ||
const gasPriceInGwei = parsedData.gasPriceInGwei; | ||
const karmaAddress = parsedData.karmaAddress; | ||
|
||
let networkURL = parsedData.networkURL; | ||
if (providerName === "polygon") { | ||
if (!process.env.ALCHEMY_API_KEY_MATIC) { | ||
console.log("set ALCHEMY_API_KEY_MATIC env variable"); | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MATIC; | ||
} else if (providerName === "polygonMumbai") { | ||
if (!process.env.ALCHEMY_API_KEY_MUMBAI) { | ||
console.log("set ALCHEMY_API_KEY_MUMBAI env variable"); | ||
return; | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MUMBAI; | ||
} | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(networkURL); | ||
const signers = await ethers.getSigners(); | ||
|
||
let EOA; | ||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Assemble the karma proxy data | ||
const karma = await ethers.getContractAt("Karma", karmaAddress); | ||
const proxyData = karma.interface.encodeFunctionData("initialize", []); | ||
|
||
// Transaction signing and execution | ||
console.log("5. EOA to deploy Karma Proxy"); | ||
console.log("You are signing the following transaction: KarmaProxy.connect(EOA).deploy()"); | ||
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); | ||
KarmaProxy = await ethers.getContractFactory("KarmaProxy"); | ||
const karmaProxy = await KarmaProxy.connect(EOA).deploy(karmaAddress, proxyData, { gasPrice }); | ||
const result = await karmaProxy.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: KarmaProxy"); | ||
console.log("Contract address:", karmaProxy.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// Wait for half a minute for the transaction completion | ||
await new Promise(r => setTimeout(r, 30000)); | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.karmaProxyAddress = karmaProxy.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --constructor-args scripts/deployment/verify_05_karma_proxy.js --network " + providerName + " " + karmaProxy.address, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*global process*/ | ||
|
||
const { ethers } = require("hardhat"); | ||
const { LedgerSigner } = require("@anders-t/ethers-ledger"); | ||
|
||
async function main() { | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
let parsedData = JSON.parse(dataFromJSON); | ||
const useLedger = parsedData.useLedger; | ||
const derivationPath = parsedData.derivationPath; | ||
const providerName = parsedData.providerName; | ||
const gasPriceInGwei = parsedData.gasPriceInGwei; | ||
const stakingFactoryAddress = parsedData.stakingFactoryAddress; | ||
const karmaProxyAddress = parsedData.karmaProxyAddress; | ||
const minResponseTimeout = parsedData.minResponseTimeout; | ||
const maxResponseTimeout = parsedData.maxResponseTimeout; | ||
|
||
let networkURL = parsedData.networkURL; | ||
if (providerName === "polygon") { | ||
if (!process.env.ALCHEMY_API_KEY_MATIC) { | ||
console.log("set ALCHEMY_API_KEY_MATIC env variable"); | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MATIC; | ||
} else if (providerName === "polygonMumbai") { | ||
if (!process.env.ALCHEMY_API_KEY_MUMBAI) { | ||
console.log("set ALCHEMY_API_KEY_MUMBAI env variable"); | ||
return; | ||
} | ||
networkURL += process.env.ALCHEMY_API_KEY_MUMBAI; | ||
} | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(networkURL); | ||
const signers = await ethers.getSigners(); | ||
|
||
let EOA; | ||
if (useLedger) { | ||
EOA = new LedgerSigner(provider, derivationPath); | ||
} else { | ||
EOA = signers[0]; | ||
} | ||
// EOA address | ||
const deployer = await EOA.getAddress(); | ||
console.log("EOA is:", deployer); | ||
|
||
// Transaction signing and execution | ||
console.log("6. EOA to deploy Mech Marketplace"); | ||
console.log("You are signing the following transaction: MechMarketplace.connect(EOA).deploy()"); | ||
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); | ||
const mechMarketplace = await MechMarketplace.connect(EOA).deploy(stakingFactoryAddress, karmaProxyAddress, | ||
{ gasPrice }); | ||
// In case when gas calculation is not working correctly on Arbitrum | ||
//const gasLimit = 60000000; | ||
//const mechMarketplace = await MechMarketplace.connect(EOA).deploy(stakingFactoryAddress, { gasLimit }); | ||
const result = await mechMarketplace.deployed(); | ||
|
||
// Transaction details | ||
console.log("Contract deployment: MechMarketplace"); | ||
console.log("Contract address:", mechMarketplace.address); | ||
console.log("Transaction:", result.deployTransaction.hash); | ||
|
||
// Wait for half a minute for the transaction completion | ||
await new Promise(r => setTimeout(r, 30000)); | ||
|
||
// Writing updated parameters back to the JSON file | ||
parsedData.mechMarketplaceAddress = mechMarketplace.address; | ||
fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); | ||
|
||
// Contract verification | ||
if (parsedData.contractVerification) { | ||
const execSync = require("child_process").execSync; | ||
execSync("npx hardhat verify --constructor-args scripts/deployment/verify_06_mech_marketplace.js --network " + providerName + " " + mechMarketplace.address, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL": "https://rpc.gnosischain.com","gasPriceInGwei":"20","agentType":"subscription","baseURI":"https://gateway.autonolas.tech/ipfs/","agentRegistryName":"AI Agent Registry","agentRegistrySymbol":"AI-AGENT-V1","agentRegistryAddress":"0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA","agentFactoryAddress": "0x4be7A91e67be963806FeFA9C1FD6C53DfC358d94","agentMechAddress": "0x77af31de935740567cf4ff1986d04b2c964a786a","agentId":"6","price":"10000000000000000","agentHash":"0x59ec5386a145869a4c8d14a3df188b32da54f4ae70bf9002df00672dbf777ffc","agentFactorySubscriptionAddress":"0x910Ca843Cad6C050Faf3f84387879b2928D40370","agentMechSubscriptionAddress":"0x327E26bDF1CfEa50BFAe35643B23D5268E41F7F9","agentIdSubscription":"3","minCreditsPerRequest":"1","subscriptionNFTAddress":"0x80A9b55F8604acC26dF2Ac6e07F9dC5B0eAa05Ce","subscriptionTokenId":"0x0ea01d5de3b34e3792db825f2a5f5595c393c68b19fd5efdacd00fcc63a53483","agentHashSubscription":"0x59ec5386a145869a4c8d14a3df188b32da54f4ae70bf9002df00672dbf777ffc"} | ||
{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL": "https://rpc.gnosischain.com","gasPriceInGwei":"20","agentType":"subscription","baseURI":"https://gateway.autonolas.tech/ipfs/","agentRegistryName":"AI Agent Registry","agentRegistrySymbol":"AI-AGENT-V1","agentRegistryAddress":"0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA","agentFactoryAddress": "0x4be7A91e67be963806FeFA9C1FD6C53DfC358d94","agentMechAddress": "0x77af31de935740567cf4ff1986d04b2c964a786a","agentId":"6","price":"10000000000000000","agentHash":"0x59ec5386a145869a4c8d14a3df188b32da54f4ae70bf9002df00672dbf777ffc","agentFactorySubscriptionAddress":"0x910Ca843Cad6C050Faf3f84387879b2928D40370","agentMechSubscriptionAddress":"0x327E26bDF1CfEa50BFAe35643B23D5268E41F7F9","agentIdSubscription":"3","minCreditsPerRequest":"1","subscriptionNFTAddress":"0x80A9b55F8604acC26dF2Ac6e07F9dC5B0eAa05Ce","subscriptionTokenId":"0x0ea01d5de3b34e3792db825f2a5f5595c393c68b19fd5efdacd00fcc63a53483","agentHashSubscription":"0x59ec5386a145869a4c8d14a3df188b32da54f4ae70bf9002df00672dbf777ffc","karmaAddress":"","karmaProxyAddress":"","stakingFactoryAddress": "0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","minResponseTimeout":"60","maxResponseTimeout":"300"} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
const parsedData = JSON.parse(dataFromJSON); | ||
const karmaAddress = parsedData.karmaAddress; | ||
const proxyData = "0x8129fc1c"; // initialize() | ||
|
||
module.exports = [ | ||
karmaAddress, | ||
proxyData | ||
]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const fs = require("fs"); | ||
const globalsFile = "globals.json"; | ||
const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); | ||
const parsedData = JSON.parse(dataFromJSON); | ||
const stakingFactoryAddress = parsedData.stakingFactoryAddress; | ||
const karmaProxyAddress = parsedData.karmaProxyAddress; | ||
const minResponseTimeout = parsedData.minResponseTimeout; | ||
const maxResponseTimeout = parsedData.maxResponseTimeout; | ||
|
||
module.exports = [ | ||
stakingFactoryAddress, | ||
karmaProxyAddress, | ||
minResponseTimeout, | ||
maxResponseTimeout | ||
]; |
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