Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested.
`pragma solidity >=0.5.0;
contract Decentragram {
string public name;
uint256 public imageCount = 0;
mapping(uint256 => Image) public images;
struct Image {
uint256 id;
string hash;
string description;
uint256 tipAmount;
address payable author;
}
event ImageCreated(
uint256 id,
string hash,
string description,
uint256 tipAmount,
address payable author
);
event ImageTipped(
uint256 id,
string hash,
string description,
uint256 tipAmount,
address payable author
);
constructor() public {
name = "Decentragram";
}
function uploadImage(string memory _imgHash, string memory _description)
public
{
// Make sure the image hash exists
require(bytes(_imgHash).length > 0);
// Make sure image description exists
require(bytes(_description).length > 0);
// Make sure uploader address exists
require(msg.sender != address(0));
// Increment image id
imageCount++;
// Add Image to the contract
images[imageCount] = Image(
imageCount,
_imgHash,
_description,
0,
msg.sender
);
// Trigger an event
**emit ImageCreated(imageCount, _imgHash, _description, 0, msg.sender);**
//the error is just because msg.sender is address and we can't pass an address to address payable
}
function tipImageOwner(uint256 _id) public payable {
// Make sure the id is valid
require(_id > 0 && _id <= imageCount);
// Fetch the image
Image memory _image = images[_id];
// Fetch the author
address payable _author = _image.author;
// Pay the author by sending them Ether
address(_author).transfer(msg.value);
//"send" and "transfer" are only available for objects of type "address payable", not "address".
// Increment the tip amount
_image.tipAmount = _image.tipAmount + msg.value;
// Update the image
images[_id] = _image;
// Trigger an event
emit ImageTipped(
_id,
_image.hash,
_image.description,
_image.tipAmount,
_author
);
}
Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested. `pragma solidity >=0.5.0;
contract Decentragram { string public name; uint256 public imageCount = 0; mapping(uint256 => Image) public images;
//the error is just because msg.sender is address and we can't pass an address to address payable }
} `