To integrate Photon Messaging into your local environment using the Hardhat/Ethers development suite, you'll need to set up some dependencies and libraries. Here’s an example with Ethers V6, Hardhat dependencies.
Example:
Copy "dependencies" : {
"@entangle_protocol/oracle-sdk" : "1.5.5" ,
"@nomicfoundation/hardhat-chai-matchers" : "^2.0.6" ,
"@nomicfoundation/hardhat-ethers" : "^3.0.5" ,
"@nomicfoundation/hardhat-ignition" : "^0.15.0" ,
"@nomicfoundation/hardhat-ignition-ethers" : "^0.15.0" ,
"@nomicfoundation/hardhat-network-helpers" : "^1.0.10" ,
"@nomicfoundation/hardhat-toolbox" : "^5.0.0" ,
"@nomicfoundation/hardhat-verify" : "^2.0.5" ,
"@nomiclabs/hardhat-ethers" : "^2.2.3" ,
"@openzeppelin/contracts" : "^4.9.6" ,
"@openzeppelin/contracts-upgradeable" : "^4.9.6" ,
"@openzeppelin/hardhat-upgrades" : "^3.0.5" ,
"@typechain/ethers-v6" : "0.5.1" ,
"@typechain/hardhat" : "^9.1.0" ,
"@types/chai" : "^4.3.1" ,
"@types/inquirer" : "^8.0.0" ,
"@types/lodash" : "^4.17.0" ,
"@types/mocha" : "^9.1.1" ,
"@types/node" : "^18.7.13" ,
"chai" : "^4.3.7" ,
"dotenv" : "^16.4.5" ,
"ethers" : "^6.11.1" ,
"hardhat-gas-reporter" : "2.1.0" ,
"inquirer" : "^8.0.0" ,
"lodash" : "^4.17.21" ,
"solidity-coverage" : "^0.8.0" ,
"ts-node" : "^10.8.2" ,
"typechain" : "^8.3.2" ,
"typescript" : "^4.9.5"
}
You need to provide the following configuration to your hardhat config file with hardhat network to mimic EOB network. Here's how to set up your Hardhat environment to replicate the EOB testnet with a chain ID of 33133:
Copy hardhat : {
accounts : {
count : 60
} ,
chainId : 33133
} ,
How to Install Entangle npm Package
To install Entangle npm package run command in your terminal:
Copy yarn add @entangle_protocol / oracle - sdk
Or
Copy npm install @entangle_protocol / oracle - sdk
Adding Artifacts to Your Local Repository
To generate Photon artifacts, simply compile a basic test contract with all necessary imports from the Photon npm package.
Copy import "@entangle_protocol/oracle-sdk/contracts/EndPoint.sol" ;
import "@entangle_protocol/oracle-sdk/contracts/EndPointGov.sol" ;
import "@entangle_protocol/oracle-sdk/contracts/MasterSmartContract.sol" ;
import "@entangle_protocol/oracle-sdk/contracts/staking/RoundManager.sol" ;
import "@entangle_protocol/oracle-sdk/contracts/staking/StakingManager.sol" ;
Following that, run the compile command to have the artifacts generated.
Example of Test Communication with Photon
To have Photon contracts deployed on your local deployment use:
Copy import {
deployAndSetupContracts
} from "@entangle_protocol/oracle-sdk/dist/test/utils/deploy" ;
let ccmContracts = await deployAndSetupContracts (
admin ,
govTransmitters ,
govExecutor ,
CONSENSUS_RATE ,
CHAIN_ID ,
await feeCollector .getAddress ()
);
Example in tests:
Copy it ( "Deploys CCM" , async () => {
let result = await deployAndSetupContracts (
admin ,
govTransmitters ,
govExecutor ,
CONSENSUS_RATE ,
CHAIN_ID ,
await feeCollector .getAddress () ,
await NGL .getAddress ()
);
staking = result .staking;
ccm = result .spotters;
streamDataContracts = result .streamDataContracts;
govProtocolId = await ccm . masterSmartContract .govProtocolId ();
})
Last updated 5 months ago