diff --git a/bin/libbfa.sh b/bin/libbfa.sh
index 2ea6f9d6dbb35abb3fcdf4a55b9416205b7a37a3..6cfbe1c9fb98244ee79033702bd0d7dbf80aebdd 100644
--- a/bin/libbfa.sh
+++ b/bin/libbfa.sh
@@ -35,19 +35,28 @@ function    cleanup
 function    geth_attach
 {
     bfaconfig node
-    geth    --cache 0 "$@" attach ipc:${BFANODEDIR}/geth.ipc
+    local cat=cat
+    if echo $- | grep -q x
+    then
+        cat="tee /dev/tty |"
+    fi
+    $cat | geth --cache 0 "$@" attach ipc:${BFANODEDIR}/geth.ipc
 }
 
 function    geth_exec_js
 {
     test    -r "$1"
-    geth_attach --exec "loadScript(\"$1\")"
+    if echo $- | grep -q x
+    then
+        sed "s//input: /" "$1"
+    fi
+    geth_attach --exec "loadScript(\"$1\")" </dev/null
 }
 
 function    geth_exec
 {
     test    -n "$1"
-    geth_attach --exec "$1"
+    geth_attach --exec "$1" </dev/null
 }
 
 function    geth_rpc
@@ -288,3 +297,36 @@ function gen_genesis
 	}
 	EOCONF
 }
+
+function contract
+{
+    bfaconfig network
+    local   contract="${BFANETWORKDIR}/contracts/${1}"
+    local   realdir=$(  realpath "${contract}"      )
+    test    -r "${realdir}"
+    local   address=$(  basename "${realdir}"       )
+    test    -n "${address}"
+    abi=$(              cat ${contract}/abi         )
+    test    -n "${abi}"
+    echo    "eth.contract(${abi}).at(\"${address}\")"
+}
+
+function contractCall
+{
+    local   name=$1
+    local   func=$2
+    shift   2
+    echo    "var contract = $( contract "${name}" );"
+    local   args=
+    for x in $*
+    do
+        args="${args}, ${x}"
+    done
+    args="${args:1},"
+    if [ "$args" = "," ]
+    then
+        args=
+    fi
+    echo    "contract.${func}.sendTransaction(${args} {from: eth.accounts[0], gas: 1000000} )"
+}
+