Reference List from another Smart Contract
Description and walkthrough for referencing the address List in another smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
// 1. import DecentralistInterface
import "INSERT_PATHING/DecentralistInterface.sol";
contract WhiteListVote {
// 2. declare decentralist variable. Insert the Voter Whitelist's contract address.
DecentralistInterface public list= DecentralistInterface(INSERT_ADDRESS);
uint256 public yesCount;
uint256 public noCount;
mapping(address => bool) public hasVoted;
function vote(bool _vote, address _address) external {
// 3. call list.onList() to return bool whether _address is on the Voter Whitelist
require(list.onList(_address),
"msg.sender must be on current voting whitelist");
require(hasVoted[_address] == false,
"msg.sender has already voted");
hasVoted[_address] = true;
if(_vote) {
yesCount++;
} else {
noCount++;
}
}
}Last updated