Hi @MWaser,
I appreciate your frustration, though once you are connected it should get easier.
I hope you don’t mind, I deployed a contract to your Proof of Authority network.
Once you have it working, you may want to spin up a new network and shut this one down, as you have shared the RPC in a public forum.
For the RPC endpoint, we need to specify the port and http (rather than https)
I gleemed this information from the Microsoft documentation:
network.js
const { projectId, mnemonic } = require('./secrets.json');
const HDWalletProvider = require('@truffle/hdwallet-provider');
const rpc_endpoint = "http://etht5zt7j-dns-reg1.eastus2.cloudapp.azure.com:8540";
module.exports = {
networks: {
development: {
protocol: 'http',
host: 'localhost',
port: 8545,
gas: 5000000,
gasPrice: 5e9,
networkId: '*',
},
rinkeby: {
provider: () => new HDWalletProvider(
mnemonic, `https://rinkeby.infura.io/v3/${projectId}`
),
networkId: 4,
gasPrice: 10e9
},
poa: {
provider: () => new HDWalletProvider(mnemonic, rpc_endpoint),
networkId: 103098097,
gasPrice: 0
}
},
};
Box.sol
I used the Box contract from the OpenZeppelin Learn guides
// contracts/Box.sol
pragma solidity ^0.5.0;
contract Box {
uint256 private value;
// Emitted when the stored value changes
event ValueChanged(uint256 newValue);
// Stores a new value in the contract
function store(uint256 newValue) public {
value = newValue;
emit ValueChanged(newValue);
}
// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}
}
I ran into another issue, I suspect that this PoA network may not support the latest EVM version.
$ npx oz call
? Pick a network poa
? Pick an instance Box at 0x288A9140dfA42BCd6328B70ba6A3600D9A1C1943
? Select which function retrieve()
✖ Calling: 'retrieve' with no arguments
Error while trying to call 0x288A9140dfA42BCd6328B70ba6A3600D9A1C1943#retrieve(). Error: VM execution error.
$ npx oz send-tx
? Pick a network poa
? Pick an instance Box at 0x288A9140dfA42BCd6328B70ba6A3600D9A1C1943
? Select which function store(newValue: uint256)
? newValue: uint256: 42
✖ Calling: 'store' with:
- newValue (uint256): "42"
Error while trying to send transaction to 0x288A9140dfA42BCd6328B70ba6A3600D9A1C1943. Error: Error: The execution failed due to an exception.
To work around this, I compiled with an earlier version of the compiler.
Compile
$ npx oz compile --solc-version 0.5.0
✓ Compiled contracts with solc 0.5.0 (commit.1d4f565a)
Deploy
I used OpenZeppelin 2.8 RC2, otherwise if you are using an earlier version, you can use oz create
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network poa
? Pick a contract to deploy Box
✓ Deployed instance of Box
0x068851224B4851506094EA525186B703E0d1fa6b
Interact
$ npx oz send-tx
? Pick a network poa
? Pick an instance Box at 0x068851224B4851506094EA525186B703E0d1fa6b
? Select which function store(newValue: uint256)
? newValue: uint256: 42
✓ Transaction successful. Transaction hash: 0x56573a27181e5a48c34c984a0023282d231586e0843843f5b15d08b4ecb660d7
Events emitted:
- ValueChanged(42)
$ npx oz call
? Pick a network poa
? Pick an instance Box at 0x068851224B4851506094EA525186B703E0d1fa6b
? Select which function retrieve()
✓ Method 'retrieve()' returned: 42
42
Let me know how you get on.