I have a very basic but functional smart contract which stores an image URL (and some other fields) for front-end use. However, while it works with shortened image URLs, most URLs are too long, causing the gas costs to skyrocket beyond the block gas limit.
Is there a more efficient way to store the URLs, or would I need to automatically shorten them somehow before sending them to the back-end?
For some context, here is my contract (As mentioned, very basic):
contract Advertisement {
string private image_url = "https://via.placeholder.com/350";
string private text = "Placeholder text";
uint private price = 0; // First user can upload their image for free (+gas);
function updateAdvertisement(string memory new_image, string memory new_text) public payable {
require(msg.value > price, "Payment must be greater than the listed price");
image_url = new_image;
text = new_text;
price = msg.value;
}
function getAdvertisement() public view returns(string memory, string memory, uint) {
return (image_url, text, price);
}
}