Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "JSON-RPC APIs (Eth Compatibility)" page #349

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const interactWithStorageContract = async (
contractAddress,
mnemonic,
providerConfig,
numberToSet,
numberToSet
) => {
try {
console.log(`Setting new number in Storage contract: ${numberToSet}`);
Expand Down Expand Up @@ -79,5 +79,5 @@ interactWithStorageContract(
contractAddress,
mnemonic,
providerConfig,
newNumber,
newNumber
);
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const compileContract = async (solidityFilePath, outputDir) => {
const bytecodePath = join(outputDir, `${name}.polkavm`);
writeFileSync(
bytecodePath,
Buffer.from(contract.evm.bytecode.object, 'hex'),
Buffer.from(contract.evm.bytecode.object, 'hex')
);
console.log(`Bytecode saved to ${bytecodePath}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const createProvider = (rpcUrl, chainId, chainName) => {
const getAbi = (contractName) => {
try {
return JSON.parse(
readFileSync(join(codegenDir, `${contractName}.json`), 'utf8'),
readFileSync(join(codegenDir, `${contractName}.json`), 'utf8')
);
} catch (error) {
console.error(
`Could not find ABI for contract ${contractName}:`,
error.message,
error.message
);
throw error;
}
Expand All @@ -31,11 +31,13 @@ const getAbi = (contractName) => {
// Reads the compiled bytecode for a given contract
const getByteCode = (contractName) => {
try {
return `0x${readFileSync(join(codegenDir, `${contractName}.polkavm`)).toString('hex')}`;
return `0x${readFileSync(
join(codegenDir, `${contractName}.polkavm`)
).toString('hex')}`;
} catch (error) {
console.error(
`Could not find bytecode for contract ${contractName}:`,
error.message,
error.message
);
throw error;
}
Expand All @@ -49,7 +51,7 @@ const deployContract = async (contractName, mnemonic, providerConfig) => {
const provider = createProvider(
providerConfig.rpc,
providerConfig.chainId,
providerConfig.name,
providerConfig.name
);
const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);
const wallet = walletMnemonic.connect(provider);
Expand All @@ -58,7 +60,7 @@ const deployContract = async (contractName, mnemonic, providerConfig) => {
const factory = new ethers.ContractFactory(
getAbi(contractName),
getByteCode(contractName),
wallet,
wallet
);
const contract = await factory.deploy();
await contract.waitForDeployment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const main = async () => {
const provider = createProvider(
PROVIDER_RPC.rpc,
PROVIDER_RPC.chainId,
PROVIDER_RPC.name,
PROVIDER_RPC.name
);
const latestBlock = await provider.getBlockNumber();
console.log(`Latest block: ${latestBlock}`);
Expand Down
1 change: 1 addition & 0 deletions develop/smart-contracts/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ nav:
- 'Native EVM Contracts': native-evm-contracts.md
- 'Parachain Contracts': parachain-contracts.md
- evm-toolkit
- 'JSON-RPC APIs': json-rpc-apis.md
Loading