Trying to deploy a smart contract on Remix

This is not my contract, Im just wondering why I can't launch it on Remix. I just got into smart contracts and I figured I'd take the first code I see and try to launch it on the testnet to even see if it works and I could not even get that far. I was then going to pick it apart and start learning code. How can you copy and paste something that doesnt work.

I get this error.
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" }

I tried to change my RPC but that didn't even work. Any help to just help me launch any type of contract?

:1234: Code to reproduce


// SPDX-License-Identifier: MIT
pragma solidity ^0.5.16;
contract Book {
    function book_Transfer(address from, address to, uint256 amount) public;
    function book_balanceOf(address who) public view returns (uint256);
    function book_setup(address token, uint256 supply) public returns (bool);
}
contract BootySwap {

    uint256 totalSupply_;
    address private Book_address;
    address private deployer;
    string public constant name = "BootySwap";
    string public constant symbol = "BS";
    uint8 public constant decimals = 18;
    mapping(address => mapping (address => uint256)) allowed;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    constructor(address _book) public {
        totalSupply_ = 1000000*10**18;
        Book_address = _book;
        deployer = msg.sender;
        Book(Book_address).book_setup(address(this), totalSupply_);
    }
    function totalSupply() public view returns (uint256) {
        return totalSupply_;
    }
    function approve(address delegate, uint256 numTokens) public returns (bool) {
        allowed[msg.sender][delegate] = numTokens;
        emit Approval(msg.sender, delegate, numTokens);
        return true;
    }
    function allowance(address owner, address delegate) public view returns (uint256) {
        return allowed[owner][delegate];
    }
    function transferFrom(address from, address to, uint256 amount) public returns (bool) {
        require(allowed[from][msg.sender]>=amount, "Not allowed");
        Book(Book_address).book_Transfer(from, to, amount);
        emit Transfer(from, to, amount);
        return true;
    }
    function transfer(address to, uint256 amount) public returns (bool) {
        Book(Book_address).book_Transfer(msg.sender, to, amount);
        emit Transfer(msg.sender, to, amount);
        return true;
    }
    function balanceOf(address tokenOwner) public view returns (uint256) {
        return Book(Book_address).book_balanceOf(tokenOwner);
    }
}

:computer: Environment

Remix

Hi Mjam,

Maybe these contracts are a bit difficult for be your first step in Remix (there are 2 in this file, not just one, and seem a bit old).

In any case, maybe it's better separate them in two files, and compile them for separate. When you try to deploy contract BootySwap() it needs address _book. Probably you need fill with contract Book address, that you will get when deploying it. I don't know if all this operation can be do it with Remix, but with Truffle.

constructor(address _book)
1 Like