#Overview
NEM testnet Faucet は testnet の XEM を Faucet形式 で手に入れることができるサイトの全ソースです。
testnet と付いているのは、現実のNEM(mainnet)ではこのような形式では既に配布するのが現実的ではないほど値が高いからです。
百聞は一見に如かず、以下のリンクに設置してありますので触ってみて下さい。
http://namuyan.dip.jp/nem/main/index.php
I recomend NEM-Api-Library ,it help you constract contents with PHP!
####作者の環境
- XAMPP (1.8.3 include PHP Ver 5.5.6 and Mysql Ver 14.14)
- NIS (NEM Beta 0.6.82)
- NEM-Api-Library (既に含まれています)
これより新しければ問題ないはずです。
PHP7でも動くはずですが未確認です。
-
ソースをDLします。
git clone https://github.com/namuyan/NEM-testnet-Faucet.git
Download sorce.git clone https://github.com/namuyan/NEM-testnet-Faucet.git
-
Apacheのルートフォルダ以下にmainファイルを作成し、
NEM-testnet-Faucet 内の全ファイルをコピーします。copyできない場合は権限の違いによるものです。
Make main folder and copy all data of NEM-testnet-Faucet to the folder.
mkdir main
andcp -r /patt/to/NEM-testnet-Faucet/* /passs/too/main/
-
htdocsと権限を一致させます。
chown -R daemon:daemon htdocs
Match the authority with * htdocs *.chown -R daemon:daemon htdocs
-
cron/.htaccess and example/.htaccess をローカル環境と一致させます。これらは他人にアクセスされないように
あなたのローカルが192.168.1.*
であるならばallow from 192.168.3.0/24
→allow from 192.168.1.0/24
-
NEMの PriKey,PubKey,Address を入手
curl http://localhost:7890/account/generate
重要:必ず記録して誰にも見せない事 -
config.php の $NEMAddress $NEMprikey $NEMpubkey に書き込む。
-
データベースを作成する。パラメータは任意の文字列にする事、例ではconfig.phpのパラメータを使用
1、root権限でログインmysql -u root -p
2、データベースを作成CREATE DATABASE nemdb CHARACTER SET utf8 COLLATE utf8_general_ci;
3、ユーザー作成CREATE USER 'nember'@'localhost' IDENTIFIED BY 'obama';
4、ユーザーに作成したDBの権限を与えるGRANT ALL PRIVILEGES ON nemdb.* TO 'nember'@'localhost';
5、mysqlよりログアウトexit
-
必要なDBを作成する。 config.phpにパラメータを書き込んだ後
example
htdocs/main/cron/makedb.php に makedb.php があるならば
http://localhost/main/cron/makedb.php
へアクセスしエラーが出なければ完了。 -
crontab にて定期実行させる。
1、main/cron 内の Deposit.php ImageReg.php SBMFaucet.php の $root_dir を直します。
2、mainファイル内でpwd
と打てばパスが出ます。
3、cronに登録crontab -e
4、以下を書き込みます。
5、*/4 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/Deposit.php >/dev/null 2>&1
*/5 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/ImageReg.php >/dev/null 2>&1
*/6 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/SBMFaucet.php >/dev/null 2>&1
8、パスは適宜直して下さい。 -
reCAPTCHAへの登録などは他のサイトを見て下さい。
function.php
の17行目のsecret
が空の為エラーが出ます。 -
あとは適宜 index.php config.php を修正して下さい。
-
Download sorce.
git clone https://github.com/namuyan/NEM-testnet-Faucet.git
-
Make main folder and copy all data of NEM-testnet-Faucet to the folder.
mkdir main
andcp -r /patt/to/NEM-testnet-Faucet/* /passs/too/main/
-
Match the authority with * htdocs *.
chown -R daemon:daemon htdocs
-
To fit local environment cron/.htaccess and example/.htaccess. DO NOT ALLOW OTHERS TO ACCESS!
If your local ip is192.168.1.12
,setallow from 192.168.3.0/24
→allow from 192.168.1.12/24
-
Create NEM account,
curl http://localhost:7890/account/generate
DO NOT SHOW OTHERS -
Write the three account data ($NEMAddress $NEMprikey $NEMpubkey) to config.php.
-
Create DB account Use diffarent parameter to Example、I use same parameter of config.php as example
1、Login as rootmysql -u root -p
2、Create databaseCREATE DATABASE nemdb CHARACTER SET utf8 COLLATE utf8_general_ci;
3、Create userCREATE USER 'nember'@'localhost' IDENTIFIED BY 'obama';
4、Grant the user access to the DBGRANT ALL PRIVILEGES ON nemdb.* TO 'nember'@'localhost';
5、Logoutexit
-
Create tables After write down to config.php
example
If makedb.php on htdocs/main/cron/makedb.php, access tohttp://localhost/main/cron/makedb.php
Check no error output. -
Run regularly by crontab.
1、To make a pass of $root_dir of Deposit.php ImageReg.php SBMFaucet.php in main/cron.
2、Get pass to typepwd
at main folder.
3、crontab -e
4、Write down followings. (pass is original)
5、*/4 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/Deposit.php >/dev/null 2>&1
*/5 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/ImageReg.php >/dev/null 2>&1
*/6 * * * * /opt/lampp/bin/php /opt/lampp/htdocs/main/cron/SBMFaucet.php >/dev/null 2>&1
http://localhost/main/index.php
にアクセスしてみましょう。
NEM-testnet-Faucet は NEM-Api-Library のサンプルプログラムみたいな扱いです。
使うならば NEM-Api-Library の方を使用したプログラムを作成する方がスッキリしています。
namuyan
Twitter @namuyan_mine
DonationCPaddress: 1BvRTmPCe47vee2CyrLi9AGeSEcrR2ciM4
DonationNEMaddress: NAN7XFG52NL3V5AW3NTSYO77AVR6X5LYRJKXWKHY
DonationMonacoin: MSYTEF7t62b9sjXt3oN9JokSjnYkvtcPFx