Algorand is a public blockchain that uses the proof of stack. It has a throughput of 750 MB of transactions per hour, which is 125 times that of Bitcoin's throughput. Algorand also solved the probabilistic finality of transactions and the blockchain forks by introducing the final and tentative consensus. The security and performance of Algorand depend on the participation of all its nodes. However, they are intelligent entities and may behave selfishly and do not cooperate to increase their benefit. Like other blockchains, Algorand uses rewards to encourage nodes to participate. This reward is distributed among all online nodes regardless of their role. Another incentive that blockchain nodes receive is transaction fees. After the block reward reaches zero, the nodes are rewarded by transaction fees. Also, Transaction fees are necessary to encourage the nodes to validate the transactions. Therefore, the amount of fee and distribution mechanism is significant for the blockchain's security and growth. The Algorand foundation does not pay transaction fees to nodes and stores them for the future. This drives selfish proposers not to validate transactions and generate empty blocks. To solve this problem, we create a perfectly competitive market for Algorand block space and obtain the optimal transaction fee and block size using the variable distribution method. We also provide an algorithm for optimizing َAlgorand consensus protocol costs, which helps it work with the least number of online nodes. In addition to the amount of reward and the method of providing it, the reward distribution mechanism is also important. This reward should be shared between the participating nodes based on their role. In addition to participating in the consensus, Algorand nodes are also responsible for validating messages and distributing them on the network. Blocks involve many transactions, so block validation is more expensive than other roles. For this reason, relay nodes may not do their role. We show that these nodes' selfish behavior increases the vulnerability of Algorand to Sybil attack; To solve this problem, we design a mechanism for identifying and punishing selfish relay nodes.