🌧️Rain

Overview of rain

Preface

Rain is a way to do multiple transactions at once to distribute (giveaway) coins to random members of your discord server.

How this works

After fetching network and account information, transactions are built using the following parameters:

/rain (value) (*contract) (*num of users)

If contract and num of users are left blank, it will distribute the value base-currency (ONE, ETH, BNB, MATIC, etc.) among five users and vice-versa.

For x num of users (5 if left blank), a transaction is built for each rain with something along the lines of this:

for i in range(numToRain):
          try:
            tx = {
            'nonce': web3.eth.get_transaction_count(address[0]) + i,
            'to': Web3.toChecksumAddress(usersRegistered[i][1]),
            'value': web3.toWei(float(value) / numToRain, 'ether'),
            'gas': estimate,
            'gasPrice': web3.eth.gasPrice,
            'chainId': chainId
            }
          except:
            #error handling - left out
          signed_tx = web3.eth.account.sign_transaction(tx, str(decrypted))
          try:
            txid = web3.eth.send_raw_transaction(signed_tx.rawTransaction)
            txids.append(txid)
          except Exception as e:
            #goes through "nonce protection" process
            #attempts transaction again with nonce + 1 and higher gas

This looks a little bit different if a contract parameter is present, although still operates fundamentally the same; these transactions will be built through a contract rather than a tx dictionary~ you can read more about the functional differences between these methods here.

After transactions are processed, a little bit of "embed magic" happens through collecting TXID's and recipient ID's, then a prompt indicating rain information is sent:

Methodology for choosing recipients

Amity uses a unique method of deciding who to send the rain to. Some similar tools do this by purely randomly choosing from a pool of active users, while others do it completely by random. Amity takes these two ideas and merges them into a method that maximizes the incentive to be active within a channel without being disruptive or unproductive.

Whenever a user speaks within a channel, they are added to a list of active users, this list is cleared and re-built every forty-five minutes. When a user firsts initiates a rain command, the application will decide which methodology to use based on two factors; one, the amount of users the sender wants to rain to (5 by default), and two, the length of the active users list.

If the amount of users to recieve the rain (numToRain) is less than or equal to the length of the active users list, Amity will randomly choose from this pool of users. Otherwise, Amity will choose from a weighted pool of random server members. This encourages constructive activity rather than spamming purely to qualify for rains as is seen with similar applications.

Last updated