Ethereum Social Media Boilerplate

hi again and tnx for Guide i did it with your help,
i have problem with encoding content and title to UTF-8 support for RTL langs, i used encodeUriComponent on btoa but it doesnt workā€¦ you have any idea about that? tnx in advance

Hi there,

Sorry for the late reply. As mentioned I donā€™t visit here everyday.

On this matter the warning is triggered by because uint8 only can hold 256 since we include 0 then the greatest number that can be held by that variable is 255. Since we didnā€™t create another variable to hold this result solidity will assign the result the value of uint8 (same as reputation added).
The compiler thinks it is very likely that an exponentiation will be greater to 255 in which case the value will overflow causing an error at runtime.

The way to fix this is to create another variable of the same type of reputation (uint80) to hold the result. This will hold as much as 2^80-1. Then we have to restrict the value of reputation added to be equal or less than 79. This will make the warning disappear I think. Good catch, I will try to push a fix when I have time.

This is not a very serious issue for you to follow the tutorial though.

Best Regards

Daniel

1 Like

how can i implement validateReputationChange you mentioned in video to change how the given reputation calculate? can you give a hint ty

That will be easy, Since the reputation validation is already implemented in the contract. You have to implemented in the client in the voting component. Changing to instead adding or taking out one unit of reputation, use the log2 of the reputation of the voter.
And one in the case the reputation of the voter is lesser or equal than 2.

1 Like

Thanks, I too have been hanging out elsewhere! Finally digging back into this project with my wingbird @cromewar, will spend some time here supporting and asking questions. Your workshop and boilerplate are awesome, really appreciate your hard work. Happy holidays & new year :star_struck:

I appreciate how clearly you write

Hi! Can you share your progress (maybe a link to your Repo?) and update us on the situation / solution to the questions you asked? Iā€™d love to see how you implemented the comments. Another workshop that explores a similar concept is https://youtu.be/mL20IZpVPuQ?t=208 which I have bolded and linked here.

Iā€™ll be checking this forum these days as I start working again on top of this boilerplate, so would welcome your open source code and help as well (seems like you are Getting Things Done!).

1 Like

Hi Saxon,

Again sorry for the late reply. To be totally honest with you I have never worked with RTL languages. So unfortunately Iā€™m afraid I wonā€™t be able to help you there.

Regards

Daniel

You are so kind fifestarr,

I have other tutorials coming soon. So expanding this repo is not very high in the pipeline. But I might drop some pointers here on where the code modifications will go in order to implement comments.

If someone finishes that part feel very welcomed to make a pull request. We will appreciate the collaboration to our public repos.

Regards

1 Like

Thanks i did comment implementation and very little changes but as i just started React and also Javascript is general just now i didnt do it in an optimized way, however if you have any react solidity experience and would like to work together i would be happy build something togetherā€¦ i try to pull request my modification as soon as i figure out how to use github XD

thanks again Daniel, as i understood anyone can use addCategory function to add category right?
if it is then how it can be restricted to contract owner only?

another question i made a donation button on every post then i tried to make a similar function as Votes named Donates but instead of adding +1 to every click adds donate amount to table for every post,i copy pasted vote functionā€¦code below doesnt work when i call it and add nothing to donates table i also added listenerā€¦ you have any idea on this? it would be great help


    event Donated (bytes32 indexed postId, address indexed postOwner, address indexed donator, uint80 postDonations);
    struct post {
        address postOwner;
        bytes32 parentPost;
        bytes32 contentId;
        int40 votes;
        bytes32 categoryId;
        uint80 donates;
    }
    function donate (bytes32 _postId, uint80  _donationAdded) external 
    {
        address _donator = msg.sender;
        bytes32 _category = postRegistry[_postId].categoryId; 
        address _contributor = postRegistry[_postId].postOwner;
        require (postRegistry[_postId].postOwner != _donator, "you cannot donate your posts");       
        postRegistry[_postId].donates += _donationAdded;
        emit Donated(_postId, _contributor, _donator, postRegistry[_postId].donates);      
    }
    function getPost(bytes32 _postId) public view returns(address, bytes32, bytes32, int72, bytes32, uint80) {   
        return (
            postRegistry[_postId].postOwner,
            postRegistry[_postId].parentPost,
            postRegistry[_postId].contentId,
            postRegistry[_postId].votes,
            postRegistry[_postId].categoryId,
            postRegistry[_postId].donates);
    }

i did a pull request with comment and donate and image upload implement

Hi Saxon,

Your function currently will only increase the .donates portion of the struct for the value added as donation.

But Iā€™m curious what that donation entails. If you want the donor to actually transfer tokens to the post owner, it will be a bit more complex than the current implementation of the votes function. Also the implementation will vary whether you want the donor to transfer native tokens (i.e. ETH) or an ERC20 token.

1 Like

Thanks will take a look later on.

Actually i did the donate transfer part with moralis docs the user now can input amount of matic (native token) and send it to postOwner of each post and doesnt bother contract for that but when i click send i want also to call this function and add donates in database thats the part which doesnt work right now

You will have to sync the donated event to the server. It will register on a different table as there is one table per synced event.

1 Like

i launched Polytter.fun you can comment donate and get reputation also there is a profile and feed for everyone ā€¦ i would appreciate you to test it and anyone intrested in developing this project with huge potential is welcomed to participate in it ā€¦ also looking for teamā€¦ huge thanks to @DanielWeb3 though for his great help

Great job and amazing to here you have your dApp launched. Will definitely take a look.

1 Like

Hey, as well you can check.
https://docs.moralis.io/moralis-server/web3/web3#events
And research
web3.eth.net.getId():
Moralis.switchNetwork("");

With this you can automate network management. Have fun.

1 Like

thanks a lot for help i will do changes