Let's assume you are using something like Web3.js as your front-end for your dApp.
You would use a function call like methods.myMethod.send()
within web3.eth.Contract
to call a specific contract function for your back-end smart contract.
The the function call will return a transactionHash
which you can immediately use.
For a link to etherscan, simply take the transaction hash and add it to the end of a standard url like below:
'https://etherscan.io/tx/' + transactionHash
You can also continue to use Web3.js to get the details from the transaction if you want to show it directly in your UX using web3.eth.getTransaction()
:
web3.eth.getTransaction('0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b§234')
.then(console.log);
> {
"hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
"nonce": 2,
"blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
"blockNumber": 3,
"transactionIndex": 0,
"from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"value": '123450000000000000',
"gas": 314159,
"gasPrice": '2000000000000',
"input": "0x57cb2fc4"
}