Integrate with Slope Wallet (Mobile)

Establishing a Connection

  1. Mobile applications and wallets are pulling up and passing references to each other using the URL scheme method.

  2. If the android device cannot pull up the other applications, you need to add the package name of the other applications to your AndroidManifest.xml.

<queries>
    <package android:name="com.xxx.yyy" />
</queries>

Connecting: Requires connection and returns wallet address

Reference format

slopewallet://wallet.slope/pay?returnSchemes=slopedapp://slope.dapp/pay?
slopePayReturn&slopePayParams={type: connect}

Formatted for post-transfer

slopewallet://wallet.slope/pay?
returnSchemes=736c6f7065646170703a2f2f736c6f70652e646170702f7061793f736c6f706550617952657475726e&slopePayParams=7b2274797065223a22636f6e6e656374227d

Description of parameters

Description of the slopePayParams structure

Wallet: Returns public key address

Return the public key address to mobile applications

slopedapp://slope.dapp/pay?
slopePayReturn=C4qGi2aeQ67GGSKcArKucxociBemWfpKCedQLuzau1M2&type=connect&error={code:200,message: testing mark}

Sending a transaction

Transaction Request

Mobile applications: Assembly Request Parameters.

Reference format

slopewallet://wallet.slope/pay?returnSchemes=slopedapp://slope.dapp/pay?slopePayReturn&slopePayParams=
{
type: pay, 
address: DYZFDHyCs5XxjyJ6KYAk3o7q1dhhiuZYaj3Ye4aTtR4r, 
memo:000001
amount: 0.001, 
symbol: SOL, 
label: testing notes, 
message: testing mark
}

Formatted for post-transfer

slopewallet://wallet.slope/pay?
returnSchemes=736c6f7065646170703a2f2f736c6f70652e646170702f7061793f736c6f706550617952657475726e&slopePayParams=7b2274797065223a22706179222c2261646472657373223a2244595a4644487943733558786a794a364b59416b336f37713164686869755a59616a33596534615474523472222c22616d6f756e74223a22302e303031222c2273706c2d746f6b656e223a2245506a465764643541756671535371654d32714e31787a7962617043384734774547476b5a77795444743176222c226c6162656c223a224d69636861656c222c226d657373616765223a225468616e6b7320796f7572efbc81222c226d656d6f223a226f72646572303031227d

Description of parameters

Description of slopePayParams structure

Mobile application transaction request code example

String _strWalletSchemeUrl =
    'slopewallet://wallet.slope/pay?returnSchemes=';
String _strMySchemeUrl = 'slopedapp://slope.dapp/pay?slopePayReturn';

void _send({Type type = Type.pay}) {
  if (_adrsCtrl.text.isEmpty || _amountCtrl.text.isEmpty) return;
  Map<String, dynamic> params = Map();
  params['type'] = (Type.pay == type) ? 'pay' : 'connect';
  if (Type.pay == type) {
    params['address'] = _adrsCtrl.text;
    params['amount'] = _amountCtrl.text;
    params['memo'] = _memoCtrl.text;
    if (_symbolCtrl.text.isNotEmpty) params['symbol'] = _symbolCtrl.text;
    if (_titleCtrl.text.isNotEmpty) params['label'] = _titleCtrl.text;
    if (_msgCtrl.text.isNotEmpty) params['message'] = _msgCtrl.text;
  }
  String strEnParams = convert.jsonEncode(params);
  String strCovertParams = _covertString(strInput: strEnParams);
  String strMyEncodeScheme = _covertString(strInput: _strMySchemeUrl);
  String strDecodeParam = Uri.encodeComponent(strCovertParams);
  _strSendScheme = _strWalletSchemeUrl +
      strMyEncodeScheme +
      '&slopePayParams=' +
      strDecodeParam;
  _launchURL(context, _strSendScheme);
}

Wallet transaction signature code example

String baseUrl = 'slopewallet://wallet.slope/pay?';
String oriUrl = uri?.toString().toLowerCase() ?? '';
if (false == oriUrl.startsWith(baseUrl)) return;

// prase scheme
String? strRetScheme = uri?.queryParameters['returnSchemes'];
if (null == strRetScheme || strRetScheme is! String) return;
if (strRetScheme.isEmpty) return;
var decodeScheme = hex.decode(strRetScheme);
var strScheme = utf8.decode(decodeScheme);
strRetScheme = strScheme.toString();

// prase params
String? strOriParam = uri?.queryParameters['slopePayParams'];
if (null == strOriParam || strOriParam is! String) return;
String strOriParamCom = Uri.decodeComponent(strOriParam);
var decode = hex.decode(strOriParamCom);
var strParam = utf8.decode(decode);
logger.d('pay param:$strParam');
var json = convert.jsonDecode(strParam);
SchemeModel model = SchemeModel.fromJson(json);
WalletEntity? wallet = context.read<WalletMainModel>().currentWallet;
if (null == wallet) return;
model.urlScheme = strRetScheme;

Signing a Message

Once the mobile applications pulls up the wallet and sends the transaction information, it indicates that the user has allowed the native wallet application to sign and send the transaction to the chain.

dynamic siginTx = await WalletMainModel().approve(
  privateKey: prKey,
  sourceAddress: coinFind.splAddress,
  sendAddress: model.address,
  mintAddressSend: mintAddress,
  amount: model.amount.toString(),
);

if (siginTx is String && siginTx.isEmpty) {
  if (showing) Navigator.pop(context);
  logger.d('Token no exist $siginTx');
  return;
}
String strRet = await WalletMainModel().push(siginTx);
String strScheme =
    model.urlScheme + '=$strRet' + '&type=${model.type, model.memo}';

Wallet: Assembly response parameters

slopedapp://slope.dapp/pay?
slopePayReturn=3U4AKtoCbUhEyBjN16aFUBgj6KRp84uJ7RS9DxHzjSeUj2bbSx8WvEqQN7DhL7JLhCSyiAZYD5QSzdtZj4CiGijv&type=pay&error={code: 80000000,message: SUCCESS.}

Last updated