<script>
	export let pkpWallet;

	const sendTransaction = async () => {
		console.log('transaction initiated');
		const from = pkpWallet.address;
		const to = '0x1A5cfC9EA11afb50011F847fb7dC07bA1e18b05A';
		const value = BigInt(10000000000000000);
		const gasLimit = 21000;

		const tx = {
			from,
			to,
			value,
			gasLimit
		};
		console.log('transaction created: ' + tx);

		const signedTx = await pkpWallet.signTransaction(tx);
		console.log('transaction signed: ' + signedTx);

		await pkpWallet.sendTransaction(signedTx);
		console.log('transaction sent');
	};
</script>

<button
	class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full shadow-lg focus:outline-none focus:shadow-outline-blue active:bg-blue-800 transition duration-150 ease-in-out"
	on:click={sendTransaction}
>
	send 0.01 xdai
</button>
