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