I am new to solidity. Anyway, I have written the following smart contract:
pragma solidity >=0.4.22 <0.7.0;
contract SP {
address BlockAddress;
bytes32 _Mhash;
function verifyHash_ASM(bytes32 _MHash) public returns (address payable Validator_address) {
bytes4 sig = bytes4(keccak256("verifyHash(string)"));
assembly {
// move pointer to free memory spot
let ptr := mload(0x40)
// put function sig at memory spot
mstore(ptr,sig)
// append argument after function sig
mstore(add(ptr,0x04), _MHash)
let result := call(
15000, // gas limit
sload(BlockAddress_slot), // to addr. append var to _slot to access storage variable
0, // not transfer any ether
ptr, // Inputs are stored at location ptr
0x20, // Inputs are 32 bytes long
ptr, //Store output over input
0x20) //Outputs are 32 bytes long
if eq(result, 0) {
revert(0, 0)
}
Validator_address := mload(ptr) // Assign output to Validator_address var
mstore(0x40,add(ptr,0x24)) // Set storage pointer to new space
}
//PayTokens(Validator_address, User_address, RepTokens);
//return Validator_address;
}
When I call the verifyHash_ASM function and parse the byte32 value 0x33c897fb3febb48f0a8a9ff79518057a9943ed879d644bba81a8a1050ccfaa4f which is equivalent to the one assigned in another contract and call the same function in that contract, I get the following error:
"transact to SP.verifyHash_ASM errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information."
The status is: "0x0 Transaction mined but execution failed"
Please note that I executed the function without values in Remix. I have also tried executing this by adding gas values and changing the function to "payable",but I still got this error.
The compiler I am using is 0.5.11 and the execution environment is JavaScript VM in Remix.
Your help and support is much appreciated
Thank you