{"id":31619445,"url":"https://github.com/multiversx/mx-distribution-sc","last_synced_at":"2025-10-06T14:06:29.574Z","repository":{"id":51158566,"uuid":"358313719","full_name":"multiversx/mx-distribution-sc","owner":"multiversx","description":"Rust Smart Contract used to distribute ESDT tokens. Used for MEX distribution.","archived":false,"fork":false,"pushed_at":"2021-05-20T21:02:28.000Z","size":309,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-01T15:08:38.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiversx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-15T15:50:28.000Z","updated_at":"2023-01-05T13:56:11.000Z","dependencies_parsed_at":"2022-08-30T13:42:10.097Z","dependency_job_id":null,"html_url":"https://github.com/multiversx/mx-distribution-sc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/multiversx/mx-distribution-sc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-distribution-sc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-distribution-sc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-distribution-sc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-distribution-sc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiversx","download_url":"https://codeload.github.com/multiversx/mx-distribution-sc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiversx%2Fmx-distribution-sc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621844,"owners_count":26017253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-06T14:06:28.157Z","updated_at":"2025-10-06T14:06:29.566Z","avatar_url":"https://github.com/multiversx.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sc-distribution-rs\n\nSmart contract used for distribution of ESDT tokens, in particular for MEX.\n\n## The big picture\n\nWorks in combination with snapshots scripts. Those are supposed to set the\nrewards for each user and each user is supposed to claim its rewards. The\nSC expects its distributed token to have been issued and have already\nbeen set LocalMint and LocalBurn roles for it.\n\n## How it works\n\n### Setting up community rewards\n\nFor setting up community rewards, the owner of the contract calls\nsetCommunityReward with the total_amount and unlock_epoch.\nThis operation is a GlobalOperation so startGlobalOperation needs\nto be called.\n\n### Setting up user rewards\n\nFor setting up user rewards, the owner of the contract calls \nsetPerUserRewards with: unlock_epoch a vector (user_address, amount).\nThis operation is a GlobalOperation so startGlobalOperation needs\nto be called. This operation can run out of gas when called with a\nlarge vector. So it should be called multiple times with smaller\nchunks. The contract does certain verifications, like the community\ntotal amount should be greater or equal with the sum of all users\nrewards set. Also it checks for duplicates in the arrays.\nIn case of human error, undo functions can be called in order\nto revert last community reward (undoLastCommunityReward)\nand user rewards (undoUserRewardsBetweenEpochs) between certain epochs.\nThese functions are also Global Operations.\n\n### Claiming rewards\n\nThe user can claim its rewards by calling claimRewards. The rewards\nwill be calculated for the last maximum of 4 reward distributions.\nAnything above that will become unclaimable. The owner of the\ncontract can call clearUnclaimableRewards in order to clear\nthe rewards accumulated and that are unclaimable. This function should\nnever run out of gas and should be called until it returns the value 0,\nwhich is the amount of user rewards cleared in that specific transaction.\nThis function wil fail if a GlobalOperation is ongoing.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-distribution-sc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiversx%2Fmx-distribution-sc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiversx%2Fmx-distribution-sc/lists"}