How would a smart contract that can map an address to its own array and have a function to push strings to the array as well as a function that can display what's in the array to mimic an address having "friends" be created? Or would there a better way to do so than what was stated above


It would look like this:

pragma solidity 0.6.6;

contract Friends {

    mapping(address => address[]) innerList;
    function addFriend(address owner, address friend) public {
    function getFriends(address owner) public returns(address[] memory){
        return innerList[owner];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.