Created
October 22, 2018 03:03
-
-
Save vchengsong/951fa855b53d8a25fd3dad9457a5263d to your computer and use it in GitHub Desktop.
eos faucet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"github.com/gin-gonic/gin" | |
//"net/http" | |
"github.com/eoscanada/eos-go" | |
token "github.com/eoscanada/eos-go/token" | |
"time" | |
) | |
func main() { | |
var api *eos.API | |
keyBag := eos.NewKeyBag() | |
keyBag.Add("***") | |
api = eos.New("http://13.125.53.113:8888") | |
api.SetSigner(keyBag) | |
m:=make(map[string]time.Time) | |
router := gin.Default() | |
router.GET("/get-token/:name", func(c *gin.Context) { | |
name := c.Param("name") | |
if time.Since(m[name]) > time.Second * 300 { | |
} | |
if len(name) != 12 { | |
c.JSON(200, gin.H{ | |
"success": "failed", | |
"message": "account length must be 12!", | |
}) | |
} | |
// Transfer | |
act := token.NewTransfer(eos.AccountName("eosfaucet111"), eos.AccountName(name), eos.NewEOSAsset(10000),"faucet distribute") | |
_, err := api.SignPushActions(act) | |
if err != nil { | |
c.JSON(200, gin.H{ | |
"success": "failed", | |
"message": err.Error(), | |
}) | |
}else { | |
c.JSON(200, gin.H{ | |
"success": "ok", | |
"message": "", | |
}) | |
m[name] = time.Now() | |
} | |
}) | |
router.Run(":8080") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Talking about EOS Faucet, Trust Dice has its own one! FREE EOS Giveaway every 6 hours! Also every user can get more EOS by playing games and staking platform token called TXT! Feel free to check it here https://trustdice.win/faucet