Description

Contributors

Work Started

Work Submitted

Work Paid

All Activity

Funder

Fishing Bot

austintgriffith

# Galleass.io Fishing Bot
## Summary
Looking for a community member to design a bot that will demonstrate how to catch and sell fish for copper automatically on https://galleass.io.
![image](https://user-images.githubusercontent.com/2653167/39960575-634c44f8-55e2-11e8-9900-7da496a3e99f.png)
## Details
Write a script that interfaces with the Galleass.io smart contracts currently deployed to Ropsten.
It should complete the following actions:
1. **Purchase a Dogger from the Harbor if one is not currently in your inventory:** This means calling the _buyShip(bytes32 model)_ function in the Harbor contract. Please load the Harbor contract address dynamically by calling _getContract(bytes32 name)_ in the Galleass contract. (The Galleass contract addresses can be found here: https://galleass.io/contracts.html)
![image](https://user-images.githubusercontent.com/2653167/39960238-632c022a-55dc-11e8-9a5a-d138b313cee1.png)
2. **Embark! (Put your Dogger into the Sea):** This means calling the _embark(uint256 shipId)_ function in the Sea contract.
![image](https://user-images.githubusercontent.com/2653167/39960274-e3b75156-55dc-11e8-9ce4-7cdab4aa2cd5.png)
3. **Set sail toward the fish you wish to catch:** This means calling _setSail(bool direction)_ in the Sea contract. You can sail east (true) or west (false) depending on what fish are available to catch. You can parse events to determine which fish to catch.
First, look through all Fish events:
_event Fish(bytes32 id, uint256 timestamp, address species, bytes32 image);_
Then, remove any that have already been caught:
_event Catch(address account, bytes32 id, uint256 timestamp, address species);_
![image](https://user-images.githubusercontent.com/2653167/39960303-a30e7746-55dd-11e8-8213-1d5fac08d62d.png)
4. **After sailing to the target fish, drop anchor:** Your ship will sail a small distance with each block that is mined. You can get your location by calling _shipLocation(address owner)_ in the Sea contract. When you are ready, call _dropAnchor()_ in the Sea contract.
![image](https://user-images.githubusercontent.com/2653167/39960321-0714eefa-55de-11e8-8d6d-0a14cf6f4985.png)
5. **Cast your line using a random bait hash:** Call the _castLine(bytes32 baitHash)_ function in the Sea contract. The contract uses a commit/reveal scheme for randomness so you will need to generate a random SHA256 called the "reveal" and then hash the reveal as your **baitHash**.
![image](https://user-images.githubusercontent.com/2653167/39960342-5585854a-55de-11e8-9820-efb75faba902.png)
6. **Attempt to reel in the fish:** Call the _reelIn(bytes32 fish, bytes32 bait)_ function in the Sea contract. The **bait** is your "reveal" from the previous step.
![image](https://user-images.githubusercontent.com/2653167/39960346-637e1ee6-55de-11e8-8d87-0fd0c32937cc.png)
7. **If a fish is caught, sell it to the Fish Monger:** Call the _sellFish(address _species,uint256 _amount)_ function in the Fish Monger contract.
![image](https://user-images.githubusercontent.com/2653167/39960283-0e952f24-55dd-11e8-8763-d653b211a868.png)
![image](https://user-images.githubusercontent.com/2653167/39960547-028856ca-55e2-11e8-8b94-88481cc823a1.png)
8. **Return to the Harbor and Disembark:** Set sail toward the harbor and call the _disembark(uint256 shipId)_ function in the Sea contract when you are close enough. This will return the Dogger to your inventory.
![image](https://user-images.githubusercontent.com/2653167/39960577-775cc792-55e2-11e8-9703-9c62d9b08ca7.png)
Don't reinvent the wheel, there is already a test script that performs similar actions here:
https://github.com/austintgriffith/galleass/blob/master/tests/embarkAndGoFishing.js
All contracts are public and verified on Etherscan. Example:
https://ropsten.etherscan.io/address/0xC15fa062d898f89e943429D056200D08614DDF89#code
The script should be publicly available in the Galleass github repo for others to use and extend.