Ethereum: Deploy transact not payable with Remix
11
As a developer using Remix, you have probably encountered errors when contracts are deployed to the Ethereum network. A current problem that arises is the “deployment of the non -payable transaction” error, which can occur when using a building -based construction tool. In this article, we will explore the causes of this error and provide step -by -step solutions to repair it.
What is the error “deploy non -payable transaction”?
The error “Deploy Transaction unpaid” occurs when Remix tries to deploy a contract which does not have a sufficient ether (ETH) balance in the Metamask portfolio. This can happen if you have deployed a contract with a non -payable function or if your contract uses a paid approach.
Causes of error “deployment of the non -payable transaction”
Here are some common causes of this error:
- Unpaid functions : Contracts that do not pay their own deployment, such as functions that do nothing (0x) or take no arguments, cannot think that the transaction is not payable.
- Payment contracts-What-You-Want : The use of a contract with an approach paid yourself can also lead to this error, because Remix does not know how many ether invoices for deployment.
- Balance of the incorrect metamask portfolio : If your Metamask portfolio has not enough ETH to cover the deployment costs, Remix will display the error “non -payable deployment transaction”.
Symptoms
If you meet the error “Deploy Transaction Unpaid” on Remix:
- The error message appears when you click on the deployment
- Your contract is successfully deployed, but the transaction fails
- You receive an error message like
0x ...
Step -by -step solutions to correct the error "deployment of the non -payable transaction"
To resolve the error "displacement of the non -payable transaction", follow these steps:
1. Update the remix and your metamask wallet
Make sure you are running the latest version of Remix (4.2.10 or later) and your Metamask wallet is up to date.
2. Check the syntax for deploying your contract
Review your contract deployment syntax to ensure that it corresponds to the typical format of deployment of contracts on Ethereum. Look for non-paid functions, approaches to payment for what yourself or incorrect arguments in the code of your contract.
3. Check the Metamask wallet balance
Make sure your Metamask wallet has sufficient ether balance to cover deployment costs. You can check this by checking the portfolio balance on the remix.
Javascript
console.log (metamask.balance ());
'
If you are not sure of your portfolio balance, try to refresh the remix or wait a short period for the balance to update.
4. Deploy usingWeb3.eth 部署 Contract ‘instead of remix.deployment.
You can deploy contracts directly from Remix using the “Web3.eth 部署 contract” function, which allows you to specify more precisely the contract syntax of the contract.
`Javascript
Const web3 = require ("web3");
Const Deployer = New Web3. Eth.DeploymentContract ();
// Replace the address of the contract and ABI with your actual contract data
Deployer.Deploy (Contractaddress, ABI);
'
5. Execute the remix in debug mode
When deploying contracts on Remix, you can run the application in debugging mode to see more detailed error messages.
Javascript
Remix Run - Debug Déploise -Contract
'
If the methodweb3.eth 部署 contract "does not work or do not return an error message like" 0x ... ", then try to execute the remix in debugging mode:
bash
Remix Run - Debug Déploise -Contract
` ‘
By following these steps, you should be able to resolve the error “deployment of the non -payable transaction” on Remix and successfully deploy your contract. If the problem persists, do not hesitate to provide more details on your project or your contract code, and I will do my best to help you more!