Send a Transaction
Once you have created your account and requested funds from the faucet you are ready to send your first transaction.
Online Faucet
You can request test funds from the Shimmer Testnet Faucet.
Iota.js
You can also find this guide in the native iota.js library
Code Example
The following example will:
- Create an account manager.
- Get Alice's account which was created in the first guide.
- Send 1 SMR to an address using the
Account.send_amount(addresses_with_amount, options)
function. Make sure to update the code sample to send to the address of your choice.
- Rust
- Nodejs
- Python
- Java
Dotenv
This example uses dotenv, which is not safe for use in production environments.
wallet/examples/05_transaction.rs
loading...
Run the example by running the following command:
cargo run --example transaction --release
wallet/bindings/nodejs/examples/4a-send-amount.js
loading...
You can run the example by running the following command from the wallet/bindings/nodejs/examples/
folder:
node 4a-send-amount.js
wallet/bindings/python/examples/3-send-transaction.py
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 3-send-transaction.py
wallet/bindings/java/examples/src/SendAmount.java
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
Transaction: 0x6b05d2023a690e60464b507653601d990bacb3eada64e04981b7c3a417c07500
Block sent: http://localhost:14265/api/core/v2/blocks/0x1b6839d2de7a7d856ab2cd66a3325a8fe0618e2d5406d1295348133abd09ee8e
Account: Account {
meta: {
index: 0,
coinType: 4219,
alias: 'Alice',
publicAddresses: [ [Object], [Object] ],
internalAddresses: [],
addressesWithUnspentOutputs: [ [Object], [Object] ],
outputs: {
'0xcb1be0ba2ce57ea3828133e23f1a278d1b37975d75ead9f3383fd640a4ba53c30000': [Object],
'0x8a9ecb96b14a57eddea704f4aa07cfe9edfa5a97080901632276b128ae7d8adb7300': [Object],
'0x607d5dfac8dd4fe05bfe62782954447334ef37b0968c690591dc8f261c3b881a4900': [Object],
'0xb2435d5b02df29da6ddf236f42683546857b7413cabf71bd20a8fd097c7e9f8e0000': [Object],
'0x52b65cf6c5e53e17ab8cc6be6832e354f4f021908e002e1fbb624e80d9eeb5fb0000': [Object],
'0xfa2cf42a07a51d4e7d2a2bcd63202400264b108938945ee53237de91d255c95c0100': [Object],
'0x7116076c27a926d5ebed504ec0a94c580920b3e9a8374197cc08e759953bc01a0000': [Object],
'0x3800d06480923efd65bfc0d5c9b17e4924cca375d1342908b39b3ca70a1cff8f0100': [Object],
'0x54bebd37b99bcf264b8ae1ebbe3dc5b0c54848f2ae24b4ded939416b6cf36b1d0000': [Object],
'0xcbe05ec9b535318f3210b3116c482c8b2d3e6f01f83d9250c61d87495355ecd70000': [Object]
},
lockedOutputs: [
'0x3800d06480923efd65bfc0d5c9b17e4924cca375d1342908b39b3ca70a1cff8f0100'
],
unspentOutputs: {
'0x54bebd37b99bcf264b8ae1ebbe3dc5b0c54848f2ae24b4ded939416b6cf36b1d0000': [Object],
'0xfa2cf42a07a51d4e7d2a2bcd63202400264b108938945ee53237de91d255c95c0100': [Object],
'0xb2435d5b02df29da6ddf236f42683546857b7413cabf71bd20a8fd097c7e9f8e0000': [Object],
'0xcbe05ec9b535318f3210b3116c482c8b2d3e6f01f83d9250c61d87495355ecd70000': [Object],
'0x8a9ecb96b14a57eddea704f4aa07cfe9edfa5a97080901632276b128ae7d8adb7300': [Object],
'0x607d5dfac8dd4fe05bfe62782954447334ef37b0968c690591dc8f261c3b881a4900': [Object],
'0xcb1be0ba2ce57ea3828133e23f1a278d1b37975d75ead9f3383fd640a4ba53c30000': [Object],
'0x52b65cf6c5e53e17ab8cc6be6832e354f4f021908e002e1fbb624e80d9eeb5fb0000': [Object],
'0x3800d06480923efd65bfc0d5c9b17e4924cca375d1342908b39b3ca70a1cff8f0100': [Object],
'0x7116076c27a926d5ebed504ec0a94c580920b3e9a8374197cc08e759953bc01a0000': [Object]
},
transactions: {
'0x91a469ff1008ed3dc21d02aa6c20d8c2c048c5f096d7c9af797d3215f824e369': [Object]
},
pendingTransactions: [
'0x91a469ff1008ed3dc21d02aa6c20d8c2c048c5f096d7c9af797d3215f824e369'
],
incomingTransactions: {}
},
messageHandler: MessageHandler { messageHandler: [External: 7f40e2e18a40] }
}
{
payload: {
type: 6,
essence: {
type: 1,
networkId: '1856588631910923207',
inputs: [Array],
inputsCommitment: '0x4a56ceb8ee05b747b73e97bdb093be9f885b6ba27562c91a1d8745d9ccfd57e1',
outputs: [Array]
},
unlocks: [ [Object] ]
},
blockId: '0x1650f471475bb0a64d3783f62b391d59b00b0eadb64ec717ac986b6725c7cfcb',
inclusionState: 'Pending',
timestamp: '1662654717453',
transactionId: '0x17670e2cda90f199c3e07188068c38ad856274e98d4913b80da8e3830db7afc4',
networkId: '1856588631910923207',
incoming: false,
note: null
}
Check your block on http://localhost:14265/api/core/v2/blocks/0x1650f471475bb0a64d3783f62b391d59b00b0eadb64ec717ac986b6725c7cfcb
Synced: {
'baseCoin': {
'total': '3490057203',
'available': '3490057203'
},
'requiredStorageDeposit': '98250300',
'nativeTokens': [
{
'tokenId': '0x08b83d49922e341d2cb45159707cfafdc9dc8fdb9d119543480dbaa5773eed8c4a0100000000',
'total': '0x64',
'available': '0x64'
}
],
'nfts': [
'0xceae643ff7c112a3adce8f55f7953ba0707ade21256a7a09068c0b47f7c62c5b',
'0x1e808b7c6e603aaeb5f718881a74fedae72981ac7d5f0294eb561cad0e653566',
'0x77133189021f50d8d66e0678e553af9f46a832a24239653d3555edb8dc859e1f',
'0x17f97185f80fa56eab974de6b7bbb80fa812d4e8e37090d166a0a41da129cebc',
'0x1b670afba8d59a445cbaf167f1fda05879362e3ea034f5c4a0979fbeb5a3964b',
'0x3f0e11e9d9f48a57d0fba43d7d1158ee673cb8055f80a5ce45ad174c962c0d8a',
'0xdc8be91d779aac048aa9001ab99ecf12cf62a4701185a95f6206a1a201bfbe7c'
],
'aliases': [
],
'foundries': [
],
'potentiallyLockedOutputs': {
'0x8dd4f722a18f3b5822216e856a98ea480fbfaa205f10c08d36dc5ab21efcc8355600': False
}[
...
]
]
Senttransaction: {
'payload': {
'type': 6,
'essence': {
'type': 1,
'networkId': '1856588631910923207',
'inputs': [
{
'type': 0,
'transactionId': '0x29ddaad7f39b1bd0e48e922984cc9556ecb895ad3ee49aec959730920af7382f',
'transactionOutputIndex': 0
}
],
'inputsCommitment': '0x2f70c8557f53f8c2483eceab991c6b7f5dad9895cd0c3785e774f26adbe04394',
'outputs': [
{
'type': 3,
'amount': '1000000',
'unlockConditions': [
{
'type': 0,
'address': {
'type': 0,
'pubKeyHash': '0x60200bad8137a704216e84f8f9acfe65b972d9f4155becb4815282b03cef99fe'
}
}
]
},
{
'type': 3,
'amount': '999000000',
'unlockConditions': [
{
'type': 0,
'address': {
'type': 0,
'pubKeyHash': '0x7ee9442e9bec8eec93ec92951819df3d728dcfec3dd21967b81e1fd1c6490ce8'
}
}
]
}
]
},
'unlocks': [
{
'type': 0,
'signature': {
'type': 0,
'publicKey': '0x4a654582703d09ea79c172d7bb475c439b8ad60234ee8adc7636a31d32970ed5',
'signature': '0xc34a5c29f627a1f664233786d29cdf8dde726970c22c7418370459ef4a8df887c007d2d05caebccda3edc34fd12eb0b1ffad849a43a1ae7057482b0420c4590c'
}
}
]
},
'blockId': '0xe187bd31ef751897a55f08dde47ef8560e3b2f96af1de77dac4f714a1e757517',
'inclusionState': 'Pending',
'timestamp': '1662654181658',
'transactionId': '0xb40d2a02805712bd88c5d3663eee228379a4acdd365fbc301d9cf79c46540c72',
'networkId': '1856588631910923207',
'incoming': False,
'note': None
}
{
"payload": {
"type": 6,
"essence": {
"type": 1,
"networkId": "1856588631910923207",
"inputs": [
{
"type": 0,
"transactionId": "0xd27ce4f6e398e9681d6e707ad2b7bc8c99183ede6a448741a1ece7036beadfbe",
"transactionOutputIndex": 0
}
],
"inputsCommitment": "0x8fb5d5215f674fb0f9633b8854efb5ecccb4293489571dc611fc7cf03d95f43e",
"outputs": [
{
"type": 3,
"amount": "1000000",
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x60200bad8137a704216e84f8f9acfe65b972d9f4155becb4815282b03cef99fe"
}
}
]
},
{
"type": 3,
"amount": "2096687300",
"nativeTokens": [
{
"id": "0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0100000000",
"amount": "0x3233"
},
{
"id": "0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0200000000",
"amount": "0x3233"
},
{
"id": "0x08429fe5864378ce70699fc2d22bb144cb86a3c4833d136e3b95c5dadfd6ba0cef0300000000",
"amount": "0x17"
}
],
"unlockConditions": [
{
"type": 0,
"address": {
"type": 0,
"pubKeyHash": "0x4cfde0600797ae07d19d67d78910e70950bfdaf716f0035e9a30b97828aaf6a2"
}
}
]
}
]
},
"unlocks": [
{
"type": 0,
"signature": {
"type": 0,
"publicKey": "0xde3152ce9d67415b9c5a042ea01caccc3f73ff1c0c77036874cb8badf9798d56",
"signature": "0x7b6f589fd0110e50130962c1674cf0bc23e73dd256618daa414249ad0d20c5a7e2ebc7d2e87e5a3049dab0a3657f0b4439e8b051f97cb8dbfe69f173106a1b07"
}
}
]
},
"blockId": "0x67bb313da84f73c52e4c6e558249a6c334ec672bb64a9192b5e6c8b6e9d09b97",
"inclusionState": "Pending",
"timestamp": "1664304732407",
"transactionId": "0x57aba1c7060c577f4404692e673910fa05dadf30e09a1cbc6aad2439628011e1",
"networkId": "1856588631910923207",
"incoming": false
}