What do you mean with assigning value from remix? You don’t to the dame with MetaMask?
imaging the contract is on bsc mainnet with one function( optimizer) where u assign values( 1 bnb) then? The whole point of this is: the contract will be deployed and when someone call the function it will transfer 1 bnb from the caller wallet to a specific wallet address.
I don’t understand what you mean. Maybe you can rephrase it?
to avoid all the confusion can you deploy the contract on bsc testnet and call the optimizer function? If not which part u did not understand?
Do you have 1 BNB on bsc testnet?
1 bnb is figure of speech, i tried it with lower value also but same error. To be clear it is possible to develop a function when user call the function it transfer a predefined amount to a predefined wallet address. right?
Yes, it is possible to do that transfer
if so then where is the problem in my code?
this code seems to work:
pragma solidity ^0.8.7;
// SPDX-License-Identifier: GPL-3.0
contract ABC {
address payable b = payable(0x9997aBff396d699FBFCEcbC17d69Bbe9343bD13e);
function make_a_transfer() public payable{
//b.transfer(msg.value);
b.send(msg.value);
}
}
you can read here about how to send a value in remix when calling that contract function
remix is out of scope here, as the contract will be deployed, and u did not predefined value, which is one of the main point
there is no difference in adding that require, I only made it simpler
so this code will work?
pragma solidity ^0.8.7;
// SPDX-License-Identifier: GPL-3.0
contract ABC {
address payable b = payable(0x9997aBff396d699FBFCEcbC17d69Bbe9343bD13e);
function make_a_transfer() public payable{
msg.value== 1*1e18;
b.send(msg.value);
}
}
well its the same, when i deployed on testnet it ask for a value but i want to send a fix amount upon calling the function:
take a look bsc testnet address:0x5CD11E236fdfD76b4c4ce5D8403f3426112a5144
it looks like I didn’t post this:
https://stackoverflow.com/questions/70936795/how-to-set-msg-value-in-remix-ide
Check that link to see how to send a value when calling a function in remix
i dont need remix, function will be called from scan. plz take a look at the address i sent at testnet
what should I see at that address?
test it in remix first to see how it works
the main point is to send a predefined amount, the code u gave me i deployed it and it ask to enter an amount while calling the function which is not what i am looking for.
how do you want to send a predefined amount?
you have to specify the amount that you want to send when you call that function, the function then checks the amount that you sent
[quote=“iammoud2, post:32, topic:21028”]
pragma solidity ^0.8.7;
// SPDX-License-Identifier: GPL-3.0
contract ABC {
address payable b = payable(0x9997aBff396d699FBFCEcbC17d69Bbe9343bD13e);
function make_a_transfer() public payable{
msg.value== 1*1e18;
b.send(msg.value);
}
}
like this.
this is the main point, i dont want to out an amount while calling the function.