1

I just testing a contract with truffle and Im wondering why the owner of the contract is set to the contract address itself.

Migrations:

const contractA= artifacts.require("ContractA");
const wbtc = artifacts.require("WBTCC");

module.exports = function(deployer, network, accounts) {
  deployer.deploy(contractA, { override:false, from: accounts[1] })
  .then(() =>deployer.deploy(wbtc, { override:false, from: accounts[1] }));
}

Test:

const rs = artifacts.require("ContractA.sol");
const wbtc = artifacts.require("WBTCC.sol");

contract('contractA', async (accounts) => {

    let instance;
    const truffleAssert = require('truffle-assertions');
    let deployAccount = accounts[1];
    before(async () => {
        iwbtc = await wbtc.deployed({from: deployAccount});
        irs = await rs.deployed({from: deployAccount});
    })
//...

ContractA:

pragma solidity >=0.4.24;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";


contract ContractA is Ownable, ReentrancyGuard {
    using SafeMath for uint256;

    constructor () public {
    }
//...

Ganach transaction

And there is the answere of the owner() function of Ownable.sol: owner = 0xe9ad029f5115e8569b281fb09c2316673E71085E

Do anyone have an idea why the owner is set to the contract address? Should not the Ownable set the owner in the constructor to the msg.sender?

Thanks if so :)

2
  • No one? Little update... found out the owner of contractA is set to the wbtc (just an erc20 standard token)
    – MaTok
    Apr 12, 2021 at 6:28
  • How do you call owner? Is it overridden by another contract? Why do you pass override:false to the deployer? Try removing build/ directory and redeploy of the contracts. Truffle artifacts sometimes get corrupted.
    – Ismael
    Apr 13, 2021 at 7:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.