Skip to content

[FIX] - Hardhat disclaimer in SC #627

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

Merged
merged 3 commits into from
May 13, 2025
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
@@ -0,0 +1,11 @@
const { JsonRpcProvider } = require('ethers');
const provider = new JsonRpcProvider('http://localhost:8545');
const wallet = new ethers.Wallet('INSERT_PRIVATE_KEY', provider);

// Deploy using direct provider instead of Hardhat's wrapper
const ContractFactory = new ethers.ContractFactory(
contractABI,
contractBytecode,
wallet
);
const contract = await ContractFactory.deploy(...constructorArgs);
14 changes: 10 additions & 4 deletions develop/smart-contracts/dev-environments/hardhat.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,17 @@ Before deploying to a live network, you can deploy your contract to a local node

!!! warning "Contract Size Limitation in Testing Environment"

When testing or deploying large contracts in Hardhat's local environment, you may encounter this error:
When deploying large contracts, you might encounter: `Error: the initcode size of this transaction is too large`.

This limitation is imposed by Hardhat's client-side checks, not by PolkaVM itself. As a workaround, you can use a direct `JsonRpcProvider`:

```javascript
--8<-- "code/develop/smart-contracts/dev-environments/hardhat/disclaimer-json-rpc-provider-alternative.js"
```

For more details, see [this GitHub issue](https://github.com/paritytech/contract-issues/issues/47#issuecomment-2790181622){target=\_blank}.


`Error: the initcode size of this transaction is too large`

This limitation is established by Hardhat based on Ethereum's default contract size limits. While Hardhat can disable this limitation, technical constraints currently prevent it from being applied to the PolkaVM test environment.

1. First, ensure you have compiled a Substrate node and the ETH RPC adapter from the Polkadot SDK. Checkout the [compatible commit](https://github.com/paritytech/polkadot-sdk/commit/c29e72a8628835e34deb6aa7db9a78a2e4eabcee){target=\_blank} from the SDK and build the node and the ETH-RPC from source:

Expand Down
Loading