- 直接引用
<script src="../dist/index.js"></script>
const gateBridge = new window.GateBridgeDemo.default({...params})
- NPM package
package.json
"gatebridge-demo": "file:../.."
import Bridge from "gatebridge-demo";
const gateBridge = new Bridge({...params})
{
assetApplyLink : 'http://xxxx', //用户增加token地址
gateLink: 'http://xxxx', //gate.io地址
locale: 'en', // 默认zh
supportedChainIds: [1, 3, 66, ...], //可扩展metamask支持的chainId
chainRule: { // 跨链白名单
'5->1337': {
tips: '',
destChainId: 78
},
'1337->5': {
tips:'Gate.io has supported asset exchange between different chains with lower service fees. Deposit your asset and withdraw what you want.',
destChainId: 5
},
...
},
chainPool: [ //可切换网络
{
name: 'Ethereum',
chainId: 5,
symbol: 'ETH',
logo: '',
bridgeAddress: '0x219e350a5b58612BF968aa1F5aFF1e52856d687a',
handler: '0x8922A6e52c35982cA598c4d1a725eE3775127ABa',
decimals: 18,
assetList: [
{
symbol: "WENUS",
name: "wenus",
logo: '',
decimals: "18",
address: '0xaFF4481D10270F50f203E0763e2597776068CBc5'
},
]
},
...
],
pairs: [ //当前跨链对网络
{
name: 'Ethereum',
chainId: 5,
symbol: 'ETH',
logo: '',
bridgeAddress: '0x219e350a5b58612BF968aa1F5aFF1e52856d687a',
handler: '0x8922A6e52c35982cA598c4d1a725eE3775127ABa',
decimals: 18,
assetList: [
{
symbol: "WENUS",
name: "wenus",
logo: '',
decimals: "18",
address: '0xaFF4481D10270F50f203E0763e2597776068CBc5'
},
]
},
{
name: 'GateChain',
chainId: 1337,
symbol: 'GT',
logo: '',
decimals: 18,
bridgeAddress: '0x830C57Bc09f137eF2cFC7c3797aA62FDA071c94A',
handler: '0x417306de14Bf393DF5d747ee555F8D4d2C3c3D83',
assetList: [
{
symbol: "WENUS",
name: "wenus",
logo: '',
decimals: "18",
address: '0x2d2490D29DBBCC0751033A76fE7906D63140Ce2d'
},
]
},
]
}
const gateBridge = new Bridge({...params});
// 渲染跨链ui
gateBridge.renderExchange(document.getElementById('#app'));
gateBridge.renderExchange(); //不传包裹容器渲染到body
// 渲染订单列表
gateBridge.renderHistory(document.getElementById('#app'));
gateBridge.renderHistory(); //不传包裹容器渲染到body