Skip to content

Commit 757f515

Browse files
Add project files.
0 parents  commit 757f515

File tree

11 files changed

+6630
-0
lines changed

11 files changed

+6630
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
out

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Remarkable Tools
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Mx.NET.SDK.SmartSend
2+
⚡ MultiversX SmartSend TypeScript SDK: Library for interacting with Smart Send contracts on MultiversX blockchain
3+
4+
## How to install?
5+
The content is delivered via npm package:
6+
##### [@remarkabletools/mx-smartsend](https://www.npmjs.com/package/@remarkabletools/mx-smartsend)
7+
8+
## Main Features
9+
- Create EGLD/Token/MetaESDT/NFT/SFT transactions for Smart Send contracts
10+
11+
## Quick start guide
12+
### Basic example
13+
```javascript
14+
const provider = new ProxyNetworkProvider('https://devnet-gateway.multiversx.com')
15+
const networkConfig = await provider.getNetworkConfig()
16+
17+
const myaddress = Address.fromBech32('MY_ADDRESS')
18+
const accountOnNetwork = await provider.getAccount(myaddress)
19+
const account = new Account(myaddress)
20+
account.update(accountOnNetwork)
21+
22+
const smartSend = new SmartSend(account, networkConfig, 'MY_CONTRACT_BECH32_ADDRESS')
23+
24+
const inputTransactions = []
25+
for (let i = 1; i < 10; i++) {
26+
inputTransactions.push(new TokenAmount('RECEIVER_ADDRESS', TokenTransfer.egldFromAmount('0.0' + i))) // TokenTransfer can also be fungibleFromAmount / metaEsdtFromAmount / nonFungible / semiFungible
27+
}
28+
29+
try {
30+
const txs = smartSend.createEGLDTransactions(inputTransactions) // or createTokenTransactions / createMetaESDTTransactions / createNFTTransactions / createSFTTransactions
31+
// sign and send egldTxs
32+
} catch (error) {
33+
console.log(error)
34+
}
35+
```
36+
37+
### Advanced example
38+
*The following example is using a wallet __signer__ that should not be used in production, only in private!*
39+
```javascript
40+
const provider = new ProxyNetworkProvider('https://devnet-gateway.multiversx.com')
41+
const networkConfig = await provider.getNetworkConfig()
42+
43+
const myaddress = Address.fromBech32('MY_ADDRESS')
44+
const accountOnNetwork = await provider.getAccount(myaddress)
45+
const account = new Account(myaddress)
46+
account.update(accountOnNetwork)
47+
48+
const pemText = await promises.readFile('/path/wallet.pem', { encoding: 'utf8' })
49+
const signer = UserSigner.fromPem(pemText)
50+
51+
const smartSend = new SmartSend(account, networkConfig, 'MY_CONTRACT_BECH32_ADDRESS')
52+
53+
const inputTransactions = []
54+
for (let i = 1; i < 10; i++) {
55+
inputTransactions.push(new TokenAmount('RECEIVER_ADDRESS', TokenTransfer.fungibleFromAmount('TOKEN-123456', i, 18))) // TokenTransfer can also be fungibleFromAmount / metaEsdtFromAmount / nonFungible / semiFungible
56+
}
57+
58+
try {
59+
const tokenTxs = smartSend.createTokenTransactions(inputTransactions)
60+
for (const tx of tokenTxs) {
61+
const serializedTransaction = tx.serializeForSigning()
62+
const transactionSignature = await signer.sign(serializedTransaction)
63+
tx.applySignature(transactionSignature)
64+
}
65+
66+
const response = await provider.sendTransactions(tokenTxs)
67+
console.log(response)
68+
} catch (error) {
69+
console.log(error)
70+
}
71+
```

0 commit comments

Comments
 (0)