• No need to build full Bitcoin/Ethereum /EOS nodes (each requires hundreds of gigabytes of space)
  • No fee, your program you call the shots
  • All money received is automatically transferred to the developer’s personal account in real time, so there is no money to steal even if it is towed.

The developer accesses the local HTTP interface to show the user the payment method, and the application accesses the local callback URL after the user makes the payment

Making the address

Steps:

1. Create a Mixin Messenger account.

Visit Mixin. one/messenger to download the corresponding mobile App.

Users in mainland China can visit a.app.qq.com/o/simple.js… download

2. Activate the developer account

Log in to developer.mixin.one and swipe the App to log in

This tutorial is useful for new developers.

Clone, build, run

git clone https://github.com/myrual/mixin-network-snapshot-golang
cd mixin-network-snapshot-golang
Copy the code
  1. Edit some configuration information
const (
	userid      = "3c5fd587-5ac3-4fb6-b294-423ba3473f7d"
	sessionid   = "42848ded-0ffd-45eb-9b46-094d5542ee01"
	private_key = `-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQDACTrT4uaB9el9qe0MUOsFrm8kpaDI9PowauMB1Ha25mpfL+5h MFqISLS5z2P89nAsXBg+KyQ2gAVA6rBwW/ZqOc1PKiJhhLBS80nzo3ayfv7OlzNG IxMyqD5izCCtPixnqpuTePoPWq4CNZlxop0VYklsWEfU0U0qqMBgmtqYfQIDAQAB AoGAR8crZed5oTn5fC73m5LjRcxdXqVJ49MtcMuC7jwr41FckRepUkpwjGAgrRMH nJXAd9Q0e4hEkNppHEqciGLXR1dQfZnaM1Gnv7mD3oSgHaH+4qAMnNOCpvwW4Eu3 yp9b1UGj9SvM3D2BrpA+MGf0E/yEJzpRcT956W6SPYYSegECQQDm4uTK+teoxr1Z agJZuCta+IhMzpxIWMob+JN/Huf7OnRcIa9JpXngg4tHOUWmZCDQdqeJMpaQc8SQ 44hba015AkEA1OyJswNIhdmvVp5P1zgREVVRK6JloYwmAtj+Qo4pWJ117LqH4w+b 491r4AeLEGh8VrZ4k6Hp+Cm783S2jTAWJQJARbWdlHdV45xVkQiDuyjy1h2RsXb0 EpfUNcvAZLIlImIMvcBh1x+CA7pTs+Zj1BAJJEee37qJYQXDBGfeRJPKKQJAVG+c x42Ew/eoTZwoIzvLoOkJcFlNHjwaksSER9ZiVQ7URdVOr99vvXQAJG45Wn9k12oy 9LCfvNan/wqIngK0tQJBAL1Wc02seEbMeWyt5jycJEhn6G8F18s9S1v0GXb4U/7/ 6Y87P3TmDLcEuCXkrbZQaCX7jVLu0BkDw8To58TWjh0= -----END RSA PRIVATE KEY-----`
	ADMIN_MessengerID = ""//this is your mixin messenger id, you can find your id in contact page.
)
Copy the code
  1. compile
go build mixin_snap.go
Copy the code
  1. run
./mixin_snap
Copy the code
  1. A test.db sqlite3 file is generated in the same directory as the database.

How to use

Get current price information for digital assets so you can calculate how much a customer should pay for digital assets

curl -X GET 'http://localhost:8080/assetsprice'
Copy the code

The price results are as follows, where Full Name is the Full Name of the currency, Symbol is the abbreviation for the exchange and wallet, USDPrice is the current dollar price of the asset, and BTCPrice is the same.

[{"Fullname":"Stellar"."Symbol":"XLM"."USDPrice":0.10357796."BTCPrice":0.00000889."Assetid":"56e63c06-b506-4ec5-885a-4a5ac17b83c1"},
	{"Fullname":"EOS"."Symbol":"EOS"."USDPrice":5.96024263."BTCPrice":0.00051165."Assetid":"6cfe566e-4aad-470b-8c9a-2fd35b49c68d"},
	{"Fullname":"Ether"."Symbol":"ETH"."USDPrice":294.61322131."BTCPrice":0.02529107."Assetid":"43d61dcd-e413-450d-80b8-101d5e903357"}]Copy the code

If the order is worth $1, the customer needs 10 XLM, or 0.17 EOS, based on the asset price.

Creating a payment request

Use the POST method to access localhost:8080/charges as follows

POST /charges

Attributes type description
currency String Currency code associated with the amount. Only EOS/XLM/ETH is supported currently
amount Float64 Positive float
customerid String This field is optional and can be used to attach an identifier of your choice to the charge. Must not exceed 64 characters
webhookurl String program will visit localhost+webhook when user pay enough currency before charge is expired
expiredafter uint the webhook will be expired after xx minutes. User can pay to an expired charge , program keep income record and will transfer asset to admin account

For example, you need to ask the client “client1245” to pay 0.001 ETH and then POST to localhost:9090/123 within 60 minutes.

Curl -d '{"currency":"ETH", "amount":0.001, "customerID ":"client1245"," webhookURL ":":9090/123", "Expiredafter ":60}' -h" Content-type: Application /json" 127.0.0.1:8080/chargesCopy the code

This instruction returns the result

{
	"Id":3."Currency":"ETH"."Amount":0.001."Customerid":"client1245"."Webhookurl":": 9090/123"."Expired_after":60."Paymentmethod": {"Name":"ETH"."PaymentAddress":"0x130D3e6655f073e33235e567E7A1e1E1f59ddD79"."PaymentAccount":""."PaymentMemo":""."Priceinusd":"310.40105841"."Priceinbtc":"0.02374051"
		},
	"Receivedamount":0."Paidstatus":0}
Copy the code

Customers need to pay the etheric lane address 0 x130d3e6655f073e33235e567e7a1e1e1f59ddd79 ETH 0.001 to complete the payment.

If you want to receive EOS

 $ curl -d '{"currency":"EOS", "amount":0.001, "customerId ":"client1245"," webhookURL ":":9090/123", "expiredAfter ":5}' -H "Content-Type: application/json"127.0.0.1:8080 / earlier
Copy the code
{
	"Id":2."Currency":"EOS"."Amount":0.001."Customerid":"client1245"."Webhookurl":": 9090/123"."Expired_after":5."Paymentmethod": {"Name":"EOS"."PaymentAddress":""."PaymentAccount":"eoswithmixin"."PaymentMemo":"a01a148f234ea8be0229a4422d21e7f3"."Priceinusd":"4.63264861"."Priceinbtc":"0.00040277"
	},
	"Receivedamount":0."Paidstatus":0
}
Copy the code

Customers need to pay to the account of EOS eoswithmixin 0.001 EOS, and must fill in the payment note a01a148f234ea8be0229a4422d21e7f3.

If you want to receive XLM

Curl -d '{"currency":"XLM", "amount":0.001, "customerID ":"client1245"," webhookURL ":":9090/123", "Expiredafter ":5}' -h" Content-type: Application /json" 127.0.0.1:8080/chargesCopy the code
{
	"Id":3."Currency":"XLM"."Amount":0.001."Customerid":"client1245"."Webhookurl":": 9090/123"."Expired_after":5."Paymentmethod": {"Name":"XLM"."PaymentAddress":""."PaymentAccount":"GD77JOIFC622O5HXU446VIKGR5A5HMSTAUKO2FSN5CIVWPHXDBGIAG7Y"."PaymentMemo":"45da67ad857c907a"."Priceinusd":"0.08866487"."Priceinbtc":"0.00000769"
	},
	"Receivedamount":0."Paidstatus":0
}
Copy the code

Customers need to pay to the account of Stellar GD77JOIFC622O5HXU446VIKGR5A5HMSTAUKO2FSN5CIVWPHXDBGIAG7Y 0.001 XLM, and 45 da67ad857c907a must fill in the payment note

There are two types of payments in Payment_method:

  1. Bitcoin/Ethereum: PaymentAddress is not empty, PaymentAccount and PaymentMemo are empty. In this case, you only need to show the user the asset name Ethereum and PaymentAddress, and the customer only needs to pay to the Ethereum address. In this example, to show the user name of assets ETH, and receiving address 0 x365da43bc7b22cd4334c3f35ed189c8357d4bed6, and you expect the etheric lane number.
  2. EOS/ Planet: PaymentAddress is empty, both PaymentAccount and PaymentMemo have contents. In this case, you need to show the user the name of the asset, the receiving account and the receiving remarks, and seriously remind the user to fill in the receiving account and the receiving remarks at the same time. If the customer forgets to fill in the remarks, it will not be able to receive the account, and there is no refund.

The Payment_method record contains the current dollar price and bitcoin price of the asset, allowing developers to calculate how much the customer should pay in digital currency based on the dollar price of the order.

{"Priceinusd":"0.10472789"."Priceinbtc":"0.00000925"}
Copy the code

List of supported currencies

Currency instructions introduce
EOS EOS. IO provids token
XLM Main Stellar token
BTC The currency
UDT Tether USD The USDT based on Bitcoin is not a token of ERC20
XRP Sharp wave currency
LTC Wright coin

Check receipt status

Access localhost:8080/charges with parameter charge_id

example

curl -X GET 'http://localhost:8080/charges? charge_id=3'Copy the code

If the customer has not paid, the result is as follows

{"Id":3, "Currency":"ETH", "Amount":0.001, "Customerid":"client1245", "Webhookurl":":9090/123", "Expired_after":60, "Paymentmethod":{ "Name":"ETH", "PaymentAddress":"0x130D3e6655f073e33235e567E7A1e1E1f59ddD79", "PaymentAccount":"", PaymentMemo :"", "Priceinusd":"310.40105841", "Priceinbtc":"0.02374051"}, "Receivedamount":0, "Paidstatus":0}Copy the code

If the customer has already paid, the result is as follows

{
	"Id":3."Currency":"ETH"."Amount":0.001."Customerid":"client1245"."Webhookurl":": 9090/123"."Expired_after":60."Paymentmethod": {"Name":"ETH"."PaymentAddress":"0x130D3e6655f073e33235e567E7A1e1E1f59ddD79"."PaymentAccount":""."PaymentMemo":""."Priceinusd":"309.75108846"."Priceinbtc":"0.02369282"
	},
	"Receivedamount":0.002."Paidstatus":2
}
Copy the code

Explanation of payment status Paidstatus

value explain
0 Not paid yet
1 Pay less than
2 Complete payment
3 Payment in excess of demand

Payment_records has payment information. One of the payment details is as follows

The callback URL

After the user has paid, the application will access the local + Webook URL

"Http://127.0.0.1" + webhookurlCopy the code

The HTTP method is POST, and the body parameter is as follows

{
	"Id":3."Currency":"ETH"."Amount":0.001."Customerid":"client1245"."Webhookurl":": 9090/123"."Expired_after":60."Paymentmethod": {"Name":"ETH"."PaymentAddress":"0x130D3e6655f073e33235e567E7A1e1E1f59ddD79"."PaymentAccount":""."PaymentMemo":""."Priceinusd":"309.75108846"."Priceinbtc":"0.02369282"
	},
	"Receivedamount":0.0021."Paidstatus":2
}
Copy the code

Do all assets belong to the developer?

  1. All assets will be automatically transferred to your designated account, free of charge, in one second.
  2. After the program restarts or exits unexpectedly, you can manually instruct the program to transfer all assets to the account you specify.

Example:

The curl -x POST - H "content-type: application/json" 127.0.0.1:8080 / moneygohomeCopy the code

The results are as follows

total 20 account will send all balance to admin
Copy the code

Confirmation time of payment

  1. EOS: 3 minutes
  2. Stellar: 2 minutes
  3. Bitcoins/USDT: 60 minutes
  4. Litecoin/Ethererum/DOGE: 120 minutes

What is confirmation time? Why care about confirmation time?

Digital currencies take a little time from the moment a user initiates a transfer request to the moment the recipient confirms that the payment cannot be rolled back. Bitcoin takes a little longer, but others take a little less time.

What assets are supported

In theory, everything supported by Mixin Network is acceptable. Now supports BTC, USDT, BCH, Ethereum and ERC20, ETC, EOS and Tokens issued on EOS, DASH, Litecoin, Doge, Horizen, MGD, NEM, XRP, XLM, Tron and tron TRC10, Zcash.

The current code base supports assets by default

Currently the default supported assets in the code are EOS and stars, as they can both be confirmed in 3 minutes.

To support more coins, place the corresponding asset variable in default_ASset_ID_group.

const (
	BTC_ASSET_ID  = "c6d0c728-2624-429b-8e0d-d9d19b6592fa"
	EOS_ASSET_ID  = "6cfe566e-4aad-470b-8c9a-2fd35b49c68d"
	USDT_ASSET_ID = "815b0b1a-2764-3736-8faa-42d694fa620a"
	ETC_ASSET_ID  = "2204c1ee-0ea2-4add-bb9a-b3719cfff93a"
	XRP_ASSET_ID  = "23dfb5a5-5d7b-48b6-905f-3970e3176e27"
	XEM_ASSET_ID  = "27921032-f73e-434e-955f-43d55672ee31"
	ETH_ASSET_ID  = "43d61dcd-e413-450d-80b8-101d5e903357"
	DASH_ASSET_ID = "6472e7e3-75fd-48b6-b1dc-28d294ee1476"
	DOGE_ASSET_ID = "6770a1e5-6086-44d5-b60f-545f9d9e8ffd"
	LTC_ASSET_ID  = "76c802a2-7c88-447f-a93e-c29c9e5dd9c8"
	SIA_ASSET_ID  = "990c4c29-57e9-48f6-9819-7d986ea44985"
	ZEN_ASSET_ID  = "a2c5d22b-62a2-4c13-b3f0-013290dbac60"
	ZEC_ASSET_ID  = "c996abc9-d94e-4494-b1cf-2a3fd3ac5714"
	BCH_ASSET_ID  = "fd11b6e3-0b87-41f1-a41f-f0e9b49e5bf0"
	XIN_ASSET_ID  = "c94ac88f-4671-3976-b60a-09064f1811e8"
	CNB_ASSET_ID  = "965e5c6e-434c-3fa9-b780-c50f43cd955c"
	XLM_ASSET_ID  = "56e63c06-b506-4ec5-885a-4a5ac17b83c1"
	TRON_ASSET_ID = "25dabac5-056a-48ff-b9f9-f67395dc407c"......) . .// to support more asset, just add them in the following array
	default_asset_id_group := []string{XLM_ASSET_ID, EOS_ASSET_ID}
Copy the code

Next development tasks:

  1. All assets can be automatically withdrawn to the developer’s own cold wallet, rather than just transferred to the Mixin Messenger account.
  2. Assets received can be automatically converted into USDT or Bitcoin via decentralized exchanges.
  3. Mixin Messenger user payments are supported.
  4. You can provide the dollar price of the assetIn the 8 a634e23254e4841c2a9c3114b3eb847d46f55fc commit has been completed.