I am new to Solidity and trying to write a smart contract which imports another smart contract using remix IDE. The first contract works fine however the second contract throws below error when I select "compile and run script":
You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag.
the second smart contract is as below:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
/**
* @title CashFlowMerchant
* @dev To determine loan repayment
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/
import "./CashFlow.sol";
contract CashFlowMerchant {
CashFlow public cashFlow_ref;
uint public customerPaymentAmt = 0;
uint public loanSettlmntAmount;
uint public merchantAmtRecvd;
uint public bankEMI;
constructor(CashFlow _addrCashFlow,
uint _customerPaymentAmt) {
cashFlow_ref = _addrCashFlow;
customerPaymentAmt = _customerPaymentAmt;
}
function repayLoan() external {
require(loanSettlmntAmount > 0, "No need to deduct amount");
if (loanSettlmntAmount > 0 && customerPaymentAmt > 10){
bankEMI = ((customerPaymentAmt * 10)/100);
if(loanSettlmntAmount > bankEMI){
merchantAmtRecvd = customerPaymentAmt - bankEMI;
}else{
bankEMI = bankEMI - loanSettlmntAmount;
merchantAmtRecvd = customerPaymentAmt - bankEMI;
}
}else{
merchantAmtRecvd = customerPaymentAmt;
}
}
}
The "compile and run script" button does two things:
@custom:dev-run-script
param. For example a script that tests the contract.Based on the context of the question, you might want to deploy the contract instead - and not run any custom script.
You can compile the Solidity contract without running a script, then switch to the "Deploy and Run transactions" tab, select your contract in the "Contract" selectbox, and hit the "Deploy" button. This will deploy the contract onto the selected network (Remix VM emulator by default), and effectively enables you to invoke the contract's functions.
Note: You can also enable "Auto compile" in the "Solidity compiler" tab. This will always compile the contract before deploying.